Beispiel #1
0
    public void CreateGraph()
    {
        mNavGraph = new SparseGraph<NavGraphNode, GraphEdge> (mRow * mColumn);

        mNavGraph.BDrawMap = mBDrawMap;

        Vector3 nodeposition = new Vector3 ();
        int nextindex = 0;
        //SparseGraph nodes data
        for (int rw = 0; rw < mRow; rw++) {
            for (int col = 0; col < mColumn; col++) {
                nodeposition = new Vector3 (rw, 0.0f, col);
                nextindex = mNavGraph.NextFreeNodeIndex;
                mNavGraph.AddNode (new NavGraphNode (nextindex, nodeposition, 0.0f, false));
            }
        }

        //SparseGraph edges data
        for (int rw = 0; rw < mRow; rw++)
        {
            for (int col = 0; col < mColumn; col++)
            {
                CreateAllNeighboursToGridNode(rw, col, mRow, mColumn);
            }
        }

        mTotalNodes = mNavGraph.NumNodes();
        mTotalEdges = mNavGraph.NumEdges ();
    }