예제 #1
0
    private void testGraph3()
    {
        WeightedGraphSearch dijkstra = new WeightedGraphSearch();
        LinkedList <Vertex> path     = new LinkedList <Vertex>();

        path = dijkstra.searchGraph(graph3.getVertex(NODE_A), graph3.getVertex(NODE_I));
        Debug.Assert(path.Count == 6);
        Debug.Assert(path.Last.Value == graph3.getVertex(NODE_A));
        Debug.Assert(path.Last.Previous.Value == graph3.getVertex(NODE_B));
        Debug.Assert(path.Last.Previous.Previous.Value == graph3.getVertex(NODE_F));
        Debug.Assert(path.Last.Previous.Previous.Previous.Value == graph3.getVertex(NODE_G));
        Debug.Assert(path.First.Next.Value == graph3.getVertex(NODE_H));
        Debug.Assert(path.First.Value == graph3.getVertex(NODE_I));
    }
예제 #2
0
    private void testGraph1()
    {
        WeightedGraphSearch dijkstra = new WeightedGraphSearch();
        LinkedList <Vertex> path     = new LinkedList <Vertex>();

        path = dijkstra.searchGraph(graph1.getVertex(NODE_A), graph1.getVertex(NODE_B));
        Debug.Assert(path.Count != 0);
        // make sure we found a path between indirectly connected nodes.
        path = dijkstra.searchGraph(graph1.getVertex(NODE_A), graph1.getVertex(NODE_D));
        Debug.Assert(path.Count != 0);
        // make sure we found no path between non-connected nodes
        path = dijkstra.searchGraph(graph1.getVertex(NODE_A), graph1.getVertex(NODE_E));
        Debug.Assert(path.Count == 0);
    }
예제 #3
0
    private void testGraph2()
    {
        WeightedGraphSearch dijkstra = new WeightedGraphSearch();
        LinkedList <Vertex> path     = new LinkedList <Vertex>();

        path = dijkstra.searchGraph(graph2.getVertex(NODE_A), graph2.getVertex(NODE_E));
        // did we find the shortest possible path?
        Debug.Assert(path.Count == 3);
        Debug.Assert(path.Last.Value == graph2.getVertex(NODE_A));
        Debug.Assert(path.Last.Previous.Value == graph2.getVertex(NODE_C));
        Debug.Assert(path.First.Value == graph2.getVertex(NODE_E));
        // we shouldn't find path between non-connected vertices
        path = dijkstra.searchGraph(graph2.getVertex(NODE_A), graph2.getVertex(NODE_F));
        Debug.Assert(path.Count == 0);
    }
예제 #4
0
    private void generateRandomCorridors()
    {
        WeightedGraphSearch djikstra = new WeightedGraphSearch();

        theMap.initPathfindingGraph();
    }