Overview
Yen's algorithm repeatedly deviates from previously found paths and keeps candidate alternatives in sorted order.
Finds several shortest loopless paths between the same two nodes.
Compact metadata for implementation and discovery.
Yen's algorithm repeatedly deviates from previously found paths and keeps candidate alternatives in sorted order.
Quick facts
Runtime and memory behavior at a glance.
Best
O(K E log V)
Average
O(K V (E + V log V))
Worst
O(K V (E + V log V))
Space
O(KV)
cost(candidate) = cost(root_path) + cost(spur_path)Ranks each alternate path built from a fixed root path and a new spur path.
Show a best route and ranked deviations from it.
Yen's K Shortest Paths operates in O(K V (E + V log V)) time and O(KV) space within the K Shortest Paths family. Key governing relation: cost(candidate) = cost(root_path) + cost(spur_path). Often compared with Dijkstra's Algorithm and Johnson's Algorithm.
What each reference supports for this entry.
Original Yen algorithm reference for loopless k-shortest path enumeration.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Yen's k-shortest paths repeatedly solves shortest-path subproblems such as Dijkstra searches.