public void BigGraphWithNoCycle() { List <string> input = new List <string>() { "10", "0 1 0 0 0 0 0 0 0 0", "1 0 1 0 0 0 0 0 0 0", "0 1 0 1 1 1 0 0 0 0", "0 0 1 0 0 0 1 1 0 0", "0 0 1 0 0 0 0 0 1 0", "0 0 1 0 0 0 0 0 0 1", "0 0 0 1 0 0 0 0 0 0", "0 0 0 1 0 0 0 0 0 0", "0 0 0 0 1 0 0 0 0 0", "0 0 0 0 0 1 0 0 0 0" }; List <int> vertexesInCycle = DfsFinder.FindCycle(GraphConverter.CreateGraph(input)); string result = ""; if (vertexesInCycle == null) { result = "A"; } else { result = "N\r\n"; vertexesInCycle.ForEach(vertex => result += vertex); } Assert.AreEqual("A", result); }
public void BigGraphWithManyCycles() { List <string> input = new List <string>() { "10", "0 1 0 1 0 0 0 1 0 0", "1 0 1 0 0 0 0 0 0 0", "0 1 0 1 1 1 0 0 0 0", "1 0 1 0 0 0 1 1 0 0", "0 0 1 0 0 0 0 0 1 1", "0 0 1 0 0 0 0 0 0 1", "0 0 0 1 0 0 0 1 0 0", "1 0 0 1 0 0 1 0 0 0", "0 0 0 0 1 0 0 0 0 0", "0 0 0 0 1 1 0 0 0 0" }; List <int> vertexesInCycle = DfsFinder.FindCycle(GraphConverter.CreateGraph(input)); string result = ""; if (vertexesInCycle == null) { result = "A"; } else { result = "N\r\n"; vertexesInCycle.ForEach(vertex => result += vertex); } Assert.IsTrue(result.CompareTo("N\r\n1234") == 0 || result.CompareTo("N\r\n048") == 0 || result.CompareTo("N\r\n0478") == 0 || result.CompareTo("N\r\n35610") == 0 || result.CompareTo("N\r\n478") == 0 || result.CompareTo("N\r\n123478") == 0 || result.CompareTo("N\r\n12348") == 0); }