January 2018
Intermediate to advanced
332 pages
7h 36m
English
Let's take a look at the pseudo code for implementing Dijkstra's algorithm:
INITIALIZE Costs, Previous Paths, Visited NodesADD each neighbor of start node to Previous PathsGET cheapest node from start node and set as current nodeWHILE node exists GET cost of current node from costs GET neighbors of current node FOREACH neighbor ADD cost of neighbor to current nodes cost as new cost IF cost of neighbor not recorded OR cost of neighbor is the lowest amongst all neighbors SET cost of neighbor as new cost SET the path of neighbor as current node MARK current node as visited GET cheapest node from start node and set as current nodeINITIALIZE responseBACKTRACK path from end to startRETURN distance and path
Read now
Unlock full access