Example #1
0
        public void Test_Algorithm_GridGraphAllNeighbours5by5(int sourceId, int destId, int expectedLength)
        {
            Graph <Vector2> graph = GraphHelper.CreateGridGraph_AllNeighbours(5, 5);

            Vertex <Vector2> source = graph.GetVertex(sourceId);
            Vertex <Vector2> dest   = graph.GetVertex(destId);

            Vertex <Vector2>[] result = new AStarRunner <Vector2>(graph).Run(source, dest, Heuristics.Manhattan).ToArray();

            int pathLength = result.Length;

            Assert.AreEqual(expectedLength, pathLength);
        }
Example #2
0
        public void Test_Algorithm_Simple3VertexGraph()
        {
            Graph <Vector2>       graph  = GraphHelper.CreateGraph_3Vertex_Simple();
            AStarRunner <Vector2> runner = new AStarRunner <Vector2>(graph);

            Vertex <Vector2>[] result = runner.Run(graph.GetVertex(1), graph.GetVertex(3), Heuristics.Manhattan)
                                        .ToArray();

            Vertex <Vector2> vertex1 = graph.GetVertex(1);
            Vertex <Vector2> vertex2 = graph.GetVertex(2);

            Assert.AreEqual(vertex1, result[0]);
            Assert.AreEqual(vertex2, result[1]);
        }