SlideShare ist ein Scribd-Unternehmen logo
1 von 13
SHORTEST ROUTE PROBLEM A Networking Model Report for DPA 702  QUANTITATIVE METHODS OF RESEARCH By: ALONA M. SALVACebu Technological University
What  is  the shortest  route  between  some node i and some other node j in  the  graph?
0.  To initialize:  ,[object Object]
b.  the distance to the origin is 0.
c.  the arc set is empty. Dijkstra’s algorithm
1.  Find  all  the  unsolved  nodes  that  are  directly  connected  by  a  single  arc  to  any solved node.   For each  unsolved node,  calculate all  of the  “candidate distances” (there  may  be  several  of  these  for  one  unsolved  node  because  it  may  directly connect to more than one solved node):  ,[object Object]
b.  the  “candidate  distance”  is  (distance  to  solved  node)  +  (length  of  arc directly connecting the solved and the unsolved node) Dijkstra’s algorithm
2.  Choose the smallest candidate distance:  ,[object Object]
b.  distance to the newly  solved node is the candidate distance.
c.  add the corresponding arc to the arc set. Dijkstra’s algorithm
3.  If  the  newly  solved  node  is  not  the  destination  node,  then  go  to  step  1. Else, stop and recover the solution:  ,[object Object]
b.  shortest route is found by tracing backwards from the destination node to the origin (or the reverse) using the arcs in the arc set.  It is usually easiest to  trace backwards because each node is reached from  exactly  one other node, but may have outward arcs to several other nodes. Dijkstra’s algorithm
Dijkstra’s algorithm

Weitere ähnliche Inhalte

Was ist angesagt?

APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENTAPPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
rsmahabir
 

Was ist angesagt? (20)

GIS - Topology
GIS - Topology GIS - Topology
GIS - Topology
 
Digital terrain model
Digital terrain modelDigital terrain model
Digital terrain model
 
APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENTAPPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
APPLICATIONS OF REMOTE SENSING AND GIS TECHNOLOGIES IN FLOOD RISK MANAGEMENT
 
GPS ERRORS
GPS ERRORS GPS ERRORS
GPS ERRORS
 
Data input techniques - GIS
Data input techniques - GISData input techniques - GIS
Data input techniques - GIS
 
Introduction to Aerial Photogrammetry
Introduction to Aerial PhotogrammetryIntroduction to Aerial Photogrammetry
Introduction to Aerial Photogrammetry
 
INTERACTION OF ELECTROMAGNETIC RADIATION WITH ATMOSPHERE
INTERACTION OF ELECTROMAGNETIC RADIATION WITH ATMOSPHEREINTERACTION OF ELECTROMAGNETIC RADIATION WITH ATMOSPHERE
INTERACTION OF ELECTROMAGNETIC RADIATION WITH ATMOSPHERE
 
.remote sensing.Ece 402 unit-2
.remote sensing.Ece 402 unit-2.remote sensing.Ece 402 unit-2
.remote sensing.Ece 402 unit-2
 
GPS (Global Positioning System)
GPS (Global Positioning System)GPS (Global Positioning System)
GPS (Global Positioning System)
 
Remote sensing
Remote sensingRemote sensing
Remote sensing
 
Spatial data for GIS
Spatial data for GISSpatial data for GIS
Spatial data for GIS
 
Chapter 5: Remote sensing
Chapter 5: Remote sensingChapter 5: Remote sensing
Chapter 5: Remote sensing
 
Image enhancement technique digital image analysis, in remote sensing ,P K MANI
Image enhancement technique  digital image analysis, in remote sensing ,P K MANIImage enhancement technique  digital image analysis, in remote sensing ,P K MANI
Image enhancement technique digital image analysis, in remote sensing ,P K MANI
 
Change detection using remote sensing and GIS
Change detection using remote sensing and GISChange detection using remote sensing and GIS
Change detection using remote sensing and GIS
 
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GISLANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
 
Historical Development of Photogrammetry
Historical Development of PhotogrammetryHistorical Development of Photogrammetry
Historical Development of Photogrammetry
 
Gnss data-processing
Gnss data-processingGnss data-processing
Gnss data-processing
 
Air Quality Mapping Using GIS
Air Quality Mapping Using GISAir Quality Mapping Using GIS
Air Quality Mapping Using GIS
 
Photogrammetry 1.
Photogrammetry 1.Photogrammetry 1.
Photogrammetry 1.
 
QUERY AND NETWORK ANALYSIS IN GIS
QUERY AND NETWORK ANALYSIS IN GISQUERY AND NETWORK ANALYSIS IN GIS
QUERY AND NETWORK ANALYSIS IN GIS
 

Andere mochten auch (9)

The Shortest Route Problem
The Shortest Route ProblemThe Shortest Route Problem
The Shortest Route Problem
 
Math project final 1
Math project final 1Math project final 1
Math project final 1
 
460 operations - 4.20
460   operations - 4.20460   operations - 4.20
460 operations - 4.20
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
 
Shortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma DijkstraShortest Path Problem: Algoritma Dijkstra
Shortest Path Problem: Algoritma Dijkstra
 
Quantitative Analysis for Management, Tenth Edition
Quantitative Analysis for Management, Tenth EditionQuantitative Analysis for Management, Tenth Edition
Quantitative Analysis for Management, Tenth Edition
 
Trafic Sign Localization & Recognition using Client-Server Architecture
Trafic Sign Localization & Recognition using Client-Server ArchitectureTrafic Sign Localization & Recognition using Client-Server Architecture
Trafic Sign Localization & Recognition using Client-Server Architecture
 
My presentation minimum spanning tree
My presentation minimum spanning treeMy presentation minimum spanning tree
My presentation minimum spanning tree
 
Pert & cpm project management
Pert & cpm   project managementPert & cpm   project management
Pert & cpm project management
 

Ähnlich wie Shortest route and mst

APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
KUSHDHIRRA2111026030
 
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
Sigma web solutions pvt. ltd.
 

Ähnlich wie Shortest route and mst (20)

OR II - M3.pptx
OR II - M3.pptxOR II - M3.pptx
OR II - M3.pptx
 
Dijkstra's algorithm presentation
Dijkstra's algorithm presentationDijkstra's algorithm presentation
Dijkstra's algorithm presentation
 
Network analysis
Network analysisNetwork analysis
Network analysis
 
Analysis and reactive measures on the blackhole attack
Analysis and reactive measures on the blackhole attackAnalysis and reactive measures on the blackhole attack
Analysis and reactive measures on the blackhole attack
 
Shortest Path Algorithm
Shortest Path AlgorithmShortest Path Algorithm
Shortest Path Algorithm
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
Pulkit 10103644
Pulkit 10103644Pulkit 10103644
Pulkit 10103644
 
Cut detection
Cut detectionCut detection
Cut detection
 
Cut detection
Cut detectionCut detection
Cut detection
 
Cut Detection in Wireless Sensor Network
Cut Detection in Wireless Sensor NetworkCut Detection in Wireless Sensor Network
Cut Detection in Wireless Sensor Network
 
Routing algorithm network layer
Routing algorithm  network layerRouting algorithm  network layer
Routing algorithm network layer
 
Ram minimum spanning tree
Ram   minimum spanning treeRam   minimum spanning tree
Ram minimum spanning tree
 
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
APznzaZLM_MVouyxM4cxHPJR5BC-TAxTWqhQJ2EywQQuXStxJTDoGkHdsKEQGd4Vo7BS3Q1npCOMV...
 
Node Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path AlgorithmsNode Path Visualizer Using Shortest Path Algorithms
Node Path Visualizer Using Shortest Path Algorithms
 
Social Network Analysis and Visualization
Social Network Analysis and VisualizationSocial Network Analysis and Visualization
Social Network Analysis and Visualization
 
Networks
NetworksNetworks
Networks
 
Modified Coverage Hole Detection Algorithm for Distributed WSNs
Modified Coverage Hole Detection Algorithm for Distributed WSNsModified Coverage Hole Detection Algorithm for Distributed WSNs
Modified Coverage Hole Detection Algorithm for Distributed WSNs
 
2512ijcsea02
2512ijcsea022512ijcsea02
2512ijcsea02
 
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
Fault tolerance in wireless sensor networks by Constrained Delaunay Triangula...
 
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
 

Mehr von Alona Salva

Mehr von Alona Salva (17)

1.2 theories of nationalism
1.2 theories of nationalism1.2 theories of nationalism
1.2 theories of nationalism
 
1.1 what is nationalism
1.1 what is nationalism1.1 what is nationalism
1.1 what is nationalism
 
Political science part xi
Political science part xiPolitical science part xi
Political science part xi
 
Does God Exist
Does God ExistDoes God Exist
Does God Exist
 
Political science part vii
Political science part viiPolitical science part vii
Political science part vii
 
Political science part viii
Political science part viiiPolitical science part viii
Political science part viii
 
Political science part ix
Political science part ixPolitical science part ix
Political science part ix
 
Political science part x
Political science part xPolitical science part x
Political science part x
 
National budget
National budgetNational budget
National budget
 
Process of research
Process of researchProcess of research
Process of research
 
Political science part iii
Political science part iiiPolitical science part iii
Political science part iii
 
Political science part ii
Political science part iiPolitical science part ii
Political science part ii
 
Political science part i
Political science part iPolitical science part i
Political science part i
 
Vienna convention on consular relations
Vienna convention on consular relationsVienna convention on consular relations
Vienna convention on consular relations
 
Social theory of International Politics
Social theory of International PoliticsSocial theory of International Politics
Social theory of International Politics
 
S R P
S R PS R P
S R P
 
F E R P A
F E  R P AF E  R P A
F E R P A
 

Kürzlich hochgeladen

0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
Renandantas16
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Dipal Arora
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
dlhescort
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
dlhescort
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
daisycvs
 

Kürzlich hochgeladen (20)

VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023Mondelez State of Snacking and Future Trends 2023
Mondelez State of Snacking and Future Trends 2023
 
Call Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine ServiceCall Girls In Panjim North Goa 9971646499 Genuine Service
Call Girls In Panjim North Goa 9971646499 Genuine Service
 
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
Call Girls Service In Old Town Dubai ((0551707352)) Old Town Dubai Call Girl ...
 
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf0183760ssssssssssssssssssssssssssss00101011 (27).pdf
0183760ssssssssssssssssssssssssssss00101011 (27).pdf
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
Enhancing and Restoring Safety & Quality Cultures - Dave Litwiller - May 2024...
 
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service NoidaCall Girls In Noida 959961⊹3876 Independent Escort Service Noida
Call Girls In Noida 959961⊹3876 Independent Escort Service Noida
 
Phases of negotiation .pptx
 Phases of negotiation .pptx Phases of negotiation .pptx
Phases of negotiation .pptx
 
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
The Path to Product Excellence: Avoiding Common Pitfalls and Enhancing Commun...
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
Call Girls in Delhi, Escort Service Available 24x7 in Delhi 959961-/-3876
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptxB.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
B.COM Unit – 4 ( CORPORATE SOCIAL RESPONSIBILITY ( CSR ).pptx
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...Ensure the security of your HCL environment by applying the Zero Trust princi...
Ensure the security of your HCL environment by applying the Zero Trust princi...
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 

Shortest route and mst

Hinweis der Redaktion

  1. Introduction to Networks Network models are an extremely important category of mathematical program that have numerous practical applications. Part of their appeal is the direct and intuitive mapping between the real world, the network diagram, and the underlying solution algorithms. Many network problems can be solved via linear programming, and in fact, special extremely fast variants of linear programming can be applied. The largest mathematical programs that are regularly solved in practice, e.g. airline crew scheduling problems, are usually network problems. For many types of network problems there are also specialized non-LP solution algorithms. We will first look at some of the classic non-LP solution methods, and later return to the idea of solving networks via LP. The solution approach to the minimal spanning tree problem is actually easier than the shortest route solution method. In the minimal spanning tree solution approach, we can start at any node in the network. However, the conventional approach is to start with node 1.
  2. Here is a technical statement of the shortest route problem: given a graph in which each arc is labeled with the distance between the two nodes that it connects, what is the shortest route between some node i and some other node j in the graph? For example, consider the graph in Figure 8.3: what is the shortest route between node A and node H? What is the length of the shortest route? In a graph this small, it is possible to solve the problem by simple inspection: try this for the graph in Figure 8.3. However, if the graph is quite large, a more organized approach is needed. Brute force enumeration of all of the possible routes is impractical in large graphs because the number of possible routes is combinatorially explosive. ry tracing out all of the routes between nodes A and H in Figure 8.3 for example: there are quite a few! Note that “shortest route problem” is also the name applied when the arc labels ar e not distances, but perhaps travel time (quickest route problem) or travel cost (cheapest route problem). The solution methods are identical in all cases. We will look first at one of the most popular methods for finding the shor test route in a graph or network: Dijkstra’s algorithm. It is an iterative method. At the nth iteration you will find the nth closest node to the start node (the origin), and the shortest route to that node. You stop iterating when the destination node is reached, even if you have not visited all of the nodes in the network. All of the nodes in the network are initially “unsolved”. A node is “solved” at each iteration when the shortest distance and route to that node is found. The length of the shortest path from the origin to a node is the “distance”: a node is solved when the distance is determined. By definition (and common sense), the distance from the origin node to the origin node is zero. Arcs which may form part of the shortest route are gradually added to the “arc set” as the method proceeds; the arc set is initially empty. Note that the method ventures up some blind alleys as it proceeds: not all of the arcs that are added to the arc set will feature in the final shortest route!
  3. You can keep track of the progress of the algorithm by constructing a table with headings such as iteration number, unsolved node connected to solved node, candidate distances and arcs, selected node, distance and arc. However, for relatively small problems it is easier to keep track by making notations directly on the diagram. We will use the following conventions for tracking the algorithm on a diagram: mark the solved nodes in boldface and label them with the distance, mark the arcs in the arc set in boldface.
  4. Let us follow the progress of Dijkstra’s algorithm as we apply it to the network shown in Figure 8.3. We will omit the initial diagram in which only node A, the origin, is solved, and so shown in boldface and labeled with the distance 0. At this point, there are 3 unsolved nodes to consider (B, C, and D) because they are directly connected to the only solved node (A). The candidate distances are AB (0+3=3), AC (0+2=2), and AD (0+5=5). The smallest candidate distance is AC, so C is now a solved node with a distance of 2 as shown in Figure 8.4.
  5. Now there are 3 unsolved nodes to consider (B, D, and E). Candidate distances are AB (0+3=3), AD (0+5=5), CD (2+2=4), and CE (2+5=7). The smallest candidate distance is AB at 3, so B is now a solved node, as shown in Figure 8.5.
  6. There are again 3 unsolved nodes to consider (F, D, and E). Candidate distances are BF (3+13=16), BD (3+2=5), AD (0+5=5), CD (2+2=4), and CE (2+5=7). The smallest candidate distance is CD at 4, so D is now a solved node, as shown in Figure 8.6.
  7. Now the unsolved nodes to consider are F, G, and E. Candidate distances are BF (3+13=16), DF (4+6=10), DG (4+3=7), DE (4+4=8), and CE (2+5=7). The smallest candidate distance is 7 with tie between DG and CE. We can choose either candidate arbitrarily and update the diagram accordingly, however we know that the candidate not chosen this time will definitely be chosen in the next iteration, so we might as well update both candidates at once, as shown in Figure 8.7.
  8. Now there are only two unsolved nodes to consider: F and H. The candidate distances are BF (3+13=16), DF (4+6=10), GF (7+2=9), and GH (7+6=13). The smallest candidate distance is 9, so F is now a solved node, as shown in Figure 8.8.
  9. Finally there is only one remaining unsolved node: H. The candidate distances are FH (9+3=12) and GH (7+6=13). So H becomes a solved node with a distance of 12, as shown in Figure 8.9. Since H is the destination node, the iterations stop. We visited every node in the network in this small example, but this will not always happen. Figure 8.9 : 7t h closest node to A is H. Finished! At this point, we know that the length of the shortest route from A to H is 12 units (kilometers perhaps). But how do we determine the route? Simply trace backwards from H to A, and then reverse the route that you find in this manner. In Figure 8.9, the reverse route is HFGDCA, and when given in the forward order this is ACDGFH. The reason for finding the route in this manner is that working backwards avoids the blind alleys that exist in the forward direction. Note that you may sometimes find a tie in the routing to an intermediate node. For example, if arc BD had a length of 1, then there would be two routes from A to D with length 4: ACD as selected in the diagram, and ABD. It doesn’t matter which one you use. In fact, you can mark both choices on the diagram as you proceed, which will remind you of the alternate routes. What makes Dijkstra’s algorithm efficient is that it calculates the lengths of only a very small subset of all of the possible routes through the graph. Once a node has been solved, the shortest path to the node from the origin is known. All paths that follow on from that node then have the benefit of the shortest path to that point.