Esempio n. 1
0
 public void UndirectedPathToFiveHasTwoVertices()
 {
     var input = CreateTestInput();
     var g = new Graph(GraphType.Undirected, input, 7);
     var search = new Dfs(g, 0);
     var path = search.PathTo(5).ToArray();
     Assert.AreEqual(2, search.DistanceTo(5));
     Assert.AreEqual(2, path[0]);
     Assert.AreEqual(5, path[1]);
 }
Esempio n. 2
0
 public void UndirectedConnectionsAreMarked()
 {
     var input = CreateTestInput();
     var g = new Graph(GraphType.Undirected, input, 7);
     var search = new Dfs(g, 0);
     Assert.IsTrue(search.Marked(2));
     Assert.IsTrue(search.Marked(3));
     Assert.IsTrue(search.Marked(5));
     Assert.IsFalse(search.Marked(1));
     Assert.IsFalse(search.Marked(4));
     Assert.IsFalse(search.Marked(6));
 }
Esempio n. 3
0
 public void UndirectedHasPathToAreCorrect()
 {
     var input = CreateTestInput();
     var g = new Graph(GraphType.Undirected, input, 7);
     var search = new Dfs(g, 0);
     Assert.IsTrue(search.HasPathTo(2));
     Assert.IsTrue(search.HasPathTo(3));
     Assert.IsTrue(search.HasPathTo(5));
     Assert.IsFalse(search.HasPathTo(0)); // No path to self
     Assert.IsFalse(search.HasPathTo(1));
     Assert.IsFalse(search.HasPathTo(4));
     Assert.IsFalse(search.HasPathTo(6));
 }