Floyd Warshall All Path Shortest Path

The Floyd Warshall All Path Shortest Path finds all the shortest path in a weighted, directed path. It can also be used to detect negative cycles.

var g = ... ; // some graph of TVertex, TEdge
var weights = ... ; // a function that maps TEdge -> double
var fw = new FloydWarshallAllShortestPathAlgorithm<TVertex, TEdge>(g, weights);

// compute

// get interresting paths,
foreach(var source in g.Vertices)
    foreach(var target in g.Vertices)
        IEnumerable<TEdge> path;
        if(fw.TryGetPath(source, target, out path)
            foreach(var edge in path)

Last edited Dec 4, 2008 at 7:10 AM by pelikhan, version 3


ido_ran Sep 4, 2012 at 9:30 AM 
I think it's bad to use var on examples because it makes it hard to understand what the actual types are.