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 = BfsFinder.FindCycle(GraphConverter.CreateGraph(input)); string result = ""; if (vertexesInCycle.Count == 0) { 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 = BfsFinder.FindCycle(GraphConverter.CreateGraph(input)); string result = ""; if (vertexesInCycle.Count == 0) { 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); }