public void TestIsCyclic() { var set = new GraphSet <string>(); var three = set.Add("3"); var four = three.AddParent("4"); Assert.False(set.IsCyclic()); three.AddChild(four); Assert.True(set.IsCyclic()); four.AddParent("5"); Assert.True(set.IsCyclic()); }
public void TestComplexIsNotCyclic() { var set = new GraphSet <string>(); var three = set.Add("3"); var two = three.AddParent("2"); var one = three.AddParent("1"); Assert.False(set.IsCyclic()); var root = two.AddParent("root"); one.AddParent(root); Assert.False(set.IsCyclic()); }
public void Test() { var set = new GraphSet <int>(); var node = set.Add(3); Check.That(set.IsCyclic()).IsFalse(); Check.That(node).IsNotNull(); Check.That(node.Value).IsEqualTo(3); var nodes = set.GetNodes().ToList(); Check.That(nodes.Count).IsEqualTo(1); Check.That(nodes.Select(x => x.Value).FirstOrDefault()).IsEqualTo(3); }
public void TestToGraphSet() { var set = new GraphSet <string>(); var three = set.Add("3"); var four = three.AddChild("4"); three.AddParent("2"); var two = three.AddParent("Two"); var one = two.AddParent("One"); two.AddParent("Un"); four.AddParent(one); var nodes = set.GetNodes(); Assert.Equal(6, nodes.Count()); Assert.False(set.IsCyclic()); }