コード例 #1
0
        public void OneWayConnectedGraphIsNotConnected()
        {
            var sut   = new KosarajusAlgorithm();
            var graph = new[]
            {
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 0, To = 1
                        }
                    }
                },
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 1, To = 2
                        }
                    }
                },
                new WeightedGraphVertex()
            };

            Assert.False(sut.IsConnected(graph));
        }
コード例 #2
0
        public void Baseline()
        {
            var sut   = new KosarajusAlgorithm();
            var graph = new[]
            {
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 0, To = 1
                        }
                    }
                },
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 1, To = 2
                        }
                    }
                },
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 2, To = 3
                        },
                        new WeightedGraphNodeEdge {
                            From = 2, To = 4
                        }
                    }
                },
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 3, To = 0
                        }
                    }
                },
                new WeightedGraphVertex
                {
                    Edges = new System.Collections.Generic.List <WeightedGraphNodeEdge>
                    {
                        new WeightedGraphNodeEdge {
                            From = 4, To = 2
                        }
                    }
                },
            };

            Assert.True(sut.IsConnected(graph));
        }
コード例 #3
0
        public void OneNodeGraphIsConnected()
        {
            var sut   = new KosarajusAlgorithm();
            var graph = new[]
            {
                new WeightedGraphVertex()
            };

            Assert.True(sut.IsConnected(graph));
        }
コード例 #4
0
        public void TwoNodeDisconnectedGraphIsNotConnected()
        {
            var sut   = new KosarajusAlgorithm();
            var graph = new[]
            {
                new WeightedGraphVertex(),
                new WeightedGraphVertex()
            };

            Assert.False(sut.IsConnected(graph));
        }