public void Cylces_TwoVerticesInCycle_OneWithTwo() { var graphDict = new Dictionary<string, IEnumerable<string>>(); graphDict.Add("a", new List<string> { "b" }); graphDict.Add("b", new List<string> { "a" }); var cycles = graphDict.GetCycles(); Assert.IsTrue(cycles.OfVertex("a").ContainsAllVertices("a", "b")); Assert.IsTrue(cycles.OfVertex("b").ContainsAllVertices("a", "b")); }
public void Cylces_StraightGraph_None() { var graphDict = new Dictionary<string, IEnumerable<string>>(); graphDict.Add("a", new List<string> { "b", "c" }); graphDict.Add("b", new List<string> { "c" }); graphDict.Add("c", new List<string> { }); var cycles = graphDict.GetCycles(); Assert.AreEqual(0, cycles.Count(c => c.VertexCount > 1)); }
public void Cylces_TwoVerticesInCycle_OneWithTwo() { var graphDict = new Dictionary <string, IEnumerable <string> >(); graphDict.Add("a", new List <string> { "b" }); graphDict.Add("b", new List <string> { "a" }); var cycles = graphDict.GetCycles(); Assert.IsTrue(cycles.OfVertex("a").ContainsAllVertices("a", "b")); Assert.IsTrue(cycles.OfVertex("b").ContainsAllVertices("a", "b")); }
public void Cylces_StraightGraph_None() { var graphDict = new Dictionary <string, IEnumerable <string> >(); graphDict.Add("a", new List <string> { "b", "c" }); graphDict.Add("b", new List <string> { "c" }); graphDict.Add("c", new List <string> { }); var cycles = graphDict.GetCycles(); Assert.AreEqual(0, cycles.Count(c => c.VertexCount > 1)); }