Skip to content

Ranked Shortest Path

Alexandre Rabérin edited this page May 12, 2020 · 1 revision

Ranked Shortest Path Algorithm

This is a variation of the Shortest Path algorithm where not only the first one, but k-th shortest paths are returned

The Hoffman-Pavlet algorithm provides an implementation this problem for directed weighted graph with positive weights.

IBidirectionalGraph<TVertex, TEdge> graph = ...;
Func<TEdge, double> edgeWeights = ...;
TVertex source = ...;
TVertex target = ...;
int maxPathCount = 5;

foreach(IEnumerable<TEdge> path in graph.RankedShortestPathHoffman(edgeWeights, source, target, maxPathCount))
{
...
}
Clone this wiki locally