Example #1
0
        public void Setup()
        {
            var bidirectionalEdgeCosts = new Dictionary <E, double>();

            // Create dict of forward and backward edges
            foreach (var edgePair in edgesCosts)
            {
                var edge     = edgePair.Key;
                var reversed = edge.Reversed();
                bidirectionalEdgeCosts.Add(edge, edgePair.Value);
                bidirectionalEdgeCosts.Add(reversed, edgePair.Value);
            }

            testGraph = new AdjacencyListGraph <string, Edge <string> >();
            foreach (string vertex in vertices)
            {
                testGraph.AddVertex(vertex);
            }

            foreach (E edge in edgesCosts.Keys)
            {
                testGraph.AddBidirectionalEdge(edge);
            }

            shortestPath = new Algorithms.DijkstraShortestPath <string, E>(testGraph, bidirectionalEdgeCosts);

            shortestPath.ComputeAllFromVertex("a");
        }
Example #2
0
        public void Setup()
        {
            testGraph = new AdjacencyListGraph <string, E>();
            foreach (string vertex in vertices)
            {
                testGraph.AddVertex(vertex);
            }

            foreach (E edge in edgesCosts.Keys)
            {
                testGraph.AddDirectedEdge(edge);
            }

            shortestPath = new Algorithms.DijkstraShortestPath <string, E>(testGraph, edgesCosts);

            shortestPath.ComputeAllFromVertex("a");
        }