Basic skeleton implementation of FW, tests to follow

This commit is contained in:
Jsor
2014-02-04 23:04:31 -07:00
parent bdc1e4fe55
commit 7f6a1beec6

View File

@@ -14,23 +14,33 @@ 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)
<<<<<<< HEAD
<<<<<<< HEAD
// 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.
>>>>>>> Basic skeleton implementation of FW, tests to follow
=======
// 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.
>>>>>>> Basic skeleton implementation of FW, tests to follow
//
// 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
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> Basic skeleton implementation of FW, tests to follow
// 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.
<<<<<<< HEAD
=======
// the cost between all pairs of vertices. Using just a little extra memory, we can remember all shortest paths
>>>>>>> Basic skeleton implementation of FW, tests to follow
=======
>>>>>>> Basic skeleton implementation of FW, tests to follow
func FloydWarshall(graph gr.CrunchGraph, cost func(gr.Node, gr.Node) float64) (AllPathFunc, SinglePathFunc) {
graph.Crunch()
_, _, _, _, _, _, cost, _ = setupFuncs(graph, cost, nil)