diff --git a/search/floydwarshall.go b/search/floydwarshall.go index 04d3748d..827296b2 100644 --- a/search/floydwarshall.go +++ b/search/floydwarshall.go @@ -14,15 +14,12 @@ type AllPathFunc func(start, goal gr.Node) (path [][]gr.Node, cost float64, err // Finds one path between start and goal, which it finds is arbitrary type SinglePathFunc func(start, goal gr.Node) (path []gr.Node, cost float64, err error) -// This function returns two functions: one that will generate all shortest paths between two nodes with ids i and j, and one that will generate just one path. +// This function returns two functions that will generate all shortest paths between two nodes with ids i and j. // // This algorithm requires the CrunchGraph interface which means it only works on nodes with dense ids since it uses an adjacency matrix. // // This algorithm isn't blazingly fast, but is relatively fast for the domain. It runs at O((number of vertices)^3), and successfully computes -// the cost between all pairs of vertices. -// -// Generating a single path should be pretty cheap after FW is done running. The AllPathFunc is likely to be considerably more expensive, -// simply because it has to effectively generate all combinations of known valid paths at each recursive step of the algorithm. +// the cost between all pairs of vertices. Using just a little extra memory, we can remember all shortest paths func FloydWarshall(graph gr.CrunchGraph, cost func(gr.Node, gr.Node) float64) (AllPathFunc, SinglePathFunc) { graph.Crunch() _, _, _, _, _, _, cost, _ = setupFuncs(graph, cost, nil)