예제 #1
0
        public void RunTest02()
        {
            RouteBetweenNodes test = new RouteBetweenNodes(graph, graph.Nodes[5], end);
            var result             = test.Run();

            Assert.IsFalse(result);
        }
예제 #2
0
        public void RouteBetweenNodes_SourceNotSameAsTarget_SourceCanNotRouteToTarget_ReturnsTrue()
        {
            // Arrange
            var node0 = new Node <int>(0);
            var node1 = new Node <int>(1);
            var node2 = new Node <int>(2);
            var node3 = new Node <int>(3);
            var node4 = new Node <int>(4);
            var node5 = new Node <int>(5);

            node0.children = new List <Node <int> > {
                node1, node4, node5
            };
            node1.children = new List <Node <int> > {
                node4, node3
            };
            node2.children = new List <Node <int> > {
                node1
            };
            node3.children = new List <Node <int> > {
                node2, node4
            };
            node4.children = new List <Node <int> >();
            node5.children = new List <Node <int> >();

            // Act
            var actual1 = RouteBetweenNodes <int> .BidirectionalSearch(node5, node3);

            var actual2 = RouteBetweenNodes <int> .BidirectionalSearch(node5, node2);

            // Assert
            actual1.Should().BeFalse();
            actual2.Should().BeFalse();
        }
예제 #3
0
        public void RunTest01()
        {
            RouteBetweenNodes test = new RouteBetweenNodes(graph, start, end);
            var result             = test.Run();

            Assert.IsTrue(result);
        }
예제 #4
0
        public void TestRouteBetweenNodes()
        {
            Graph g = CreateNewGraph();

            Node[] n     = g.GetNodes();
            Node   start = n[3];
            Node   end   = n[5];

            Assert.True(RouteBetweenNodes.Search(g, start, end));
        }
예제 #5
0
        public void RouteBetweenNodes_SourceSameAsTarget_ReturnsTrue()
        {
            // Arrange
            var node = new Node <int>(3);

            // Act
            var actual = RouteBetweenNodes <int> .BidirectionalSearch(node, node);

            // Assert
            actual.Should().BeTrue();
        }
예제 #6
0
        public void RouteBetweenNodesDepthFirstTest(Graph <int> aGraph, GraphNode <int> node1, GraphNode <int> node2, bool expectedResult)
        {
            foreach (var node in aGraph.nodes)
            {
                node.visited = false;
            }

            bool result = RouteBetweenNodes.IsRouteBetweenNodesDepthFirst(node1, node2);

            Assert.Equal(expectedResult, result);
        }
예제 #7
0
        public void RouteBetweenNodesTest()
        {
            var(a, b) = GraphNode.GetConnected();
            var resultOne = RouteBetweenNodes.Run(a, b);

            Assert.True(resultOne);

            var(c, d) = GraphNode.GetNotConnected();
            var resultTwo = RouteBetweenNodes.Run(c, d);

            Assert.False(resultTwo);
        }
예제 #8
0
        public void RouteBetweenNodesBreadthFirstTest(Graph <int> aGraph, GraphNode <int> node1, GraphNode <int> node2, bool expectedResult)
        {
            bool result = RouteBetweenNodes.IsRouteBetweenNodesBreadthFirst(aGraph, node1, node2);

            Assert.Equal(expectedResult, result);
        }