public void DisconnectedGraphCycleIsDetected() { var graph = new[] { new GraphVertex <int> { Value = 1, }, new GraphVertex <int> { Value = 2, AdjacentVertices = new System.Collections.Generic.List <int> { 2 } }, new GraphVertex <int> { Value = 2, AdjacentVertices = new System.Collections.Generic.List <int> { 1 } }, }; Assert.True(CycleDetector.IsCyclic(graph)); }
public void CycleIsNotDetectedForNonCycledGraph() { var graph = new[] { new GraphVertex <int> { Value = 1, AdjacentVertices = new System.Collections.Generic.List <int> { 1 } }, new GraphVertex <int> { Value = 2, }, }; Assert.False(CycleDetector.IsCyclic(graph)); }