Esempio n. 1
0
 public void UndirectedPathToFiveHasOneVertices()
 {
     var input = CreateTestInput();
     var g = new Graph(GraphType.Undirected, input, 7);
     var search = new Bfs(g, 0);
     Assert.AreEqual(1, search.DistanceTo(5));
 }
Esempio n. 2
0
 public void UndirectedConnectionsAreMarked()
 {
     var input = CreateTestInput();
     var g = new Graph(GraphType.Undirected, input, 7);
     var search = new Bfs(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 Bfs(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));
 }