public void IsCyclic_False_03() { var n1 = new GraphNode("1"); var n2 = new GraphNode("2"); var n3 = new GraphNode("3"); n1.Neighbors = new[] { n2, n3 }; n2.Neighbors = new[] { n3 }; var graph = new Graph(new[] { n1, n2, n3 }); Assert.IsFalse(graph.IsCyclic()); }
public void IsCyclic_True_02() { var n1 = new GraphNode("1"); var n2 = new GraphNode("2"); var n3 = new GraphNode("3"); n1.Neighbors = new[] { n2 }; n2.Neighbors = new[] { n3 }; n3.Neighbors = new[] { n1 }; var graph = new Graph(new[] { n1, n2, n3 }); Assert.IsTrue(graph.IsCyclic()); }