From 7f6a1beec6bf4815379d66e0e6816b3ff3d6eafc Mon Sep 17 00:00:00 2001 From: Jsor Date: Tue, 4 Feb 2014 23:04:31 -0700 Subject: [PATCH] Basic skeleton implementation of FW, tests to follow --- search/floydwarshall.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/search/floydwarshall.go b/search/floydwarshall.go index 9e749d6a..e5b88c33 100644 --- a/search/floydwarshall.go +++ b/search/floydwarshall.go @@ -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)