Data structures Middle School once, GIS spatial analysis to learn again ~ ~ ~ ~
Dijkstra's algorithm is a typical greedy algorithm, each time to find the source point nearest point
Zhang Kangcong a textbook example:
Impedance matrix of six nodes
3 is known as a point source, requires starting from the start point 3, point 3 obtains the shortest path to each point
① At point 3 to point 1,2,4,6 shortest path route
min (P3-1, P3-2, P3-4, P3-6 ) = min (53,39,25, . 19 ) , the selected shortest P3-6 , from . 3 to . 6 shortest path is the P3-6
② the point 6 as Stepping Stone , from 6 o'clock start down the path to find a little compared with the first step is not selected path
min (P3-6-5, P3-1, P3-2, P3-4 ) = min (32,53,39, 25 ) , the selected shortest P3-4 , from . 3 to . 4 the shortest path is the P3 -4
③ the point 4 as Stepping Stone , 4 from the start point down a little to find the path
min (P3-4-5, P3-4-1, P3-6-5 , P3-1, P3-2) = min (38,83, 32 , 53,39) , the selected shortest P3-6- 5 , from . 3 to 5 the shortest path is the P3-6-5
④ min (P3-4-1, P3-1, P3-2 ) = min (83,53, 39 ) , from . 3 to 2 shortest path is the P3-2
⑤ min (P3-4-1, P3-1) = min (83, 53 is ) , from . 3 to . 1 shortest path is the P3-1
Dijkstra every step is selecting an alternative path in the list of shortest path