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"); }
public void TestCreatingBidrectionalEdge() { testGraph.AddVertex("a"); testGraph.AddVertex("b"); var a_b = new E("a", "b"); var b_a = a_b.Reversed(); testGraph.AddBidirectionalEdge(a_b); // Collect all the edges var collectedEdges = new List <E>(testGraph.AllEdgeIterator()); Assert.AreEqual(collectedEdges.Count, 2); // Make sure both b_a and a_b are in the graph Assert.IsTrue(collectedEdges.Contains(a_b)); Assert.IsTrue(collectedEdges.Contains(b_a)); }