Пример #1
0
        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));
        }
Пример #2
0
        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));
        }