コード例 #1
0
        public void MayHaveDuplicateEdges()
        {
            var graph = typeof(DirectedGraph)
                        .Invoking(_ => DirectedGraph.Of(
                                      GraphFactory.CreateEdges("A-B", "A-B"),
                                      GraphFactory.CreateNodes("A", "B")))
                        .Should().NotThrow()
                        .Subject;

            graph.EdgeCount.Should().Be(2);
        }
コード例 #2
0
        public void PathDoesNotVisitOtherNodes()
        {
            var path = GraphFactory.CreateEdges("A-B", "B-C", "C-D", "D-E");

            path.Visits(NodeIdentity.Of("Q")).Should().BeFalse();
        }
コード例 #3
0
        public void PathVisitsNodeInMiddle()
        {
            var path = GraphFactory.CreateEdges("A-B", "B-C", "C-D", "D-E");

            path.Visits(NodeIdentity.Of("C")).Should().BeTrue();
        }
コード例 #4
0
        public void PathContainingACycleIsNotACycle()
        {
            var path = GraphFactory.CreateEdges("A-B", "B-C", "C-A", "A-D");

            path.DescribesCycle().Should().BeFalse();
        }
コード例 #5
0
        public void PathLongerThan2WhichEndsWhereItStartsIsACycle()
        {
            var path = GraphFactory.CreateEdges("A-B", "B-C", "C-A");

            path.DescribesCycle().Should().BeTrue();
        }
コード例 #6
0
        public void ANodeLeadingToItselfIsACycle()
        {
            var path = GraphFactory.CreateEdges("A-A");

            path.DescribesCycle().Should().BeTrue();
        }
コード例 #7
0
        public void AnEmptyPathIsNotACycle()
        {
            var path = GraphFactory.CreateEdges();

            path.DescribesCycle().Should().BeFalse();
        }