public LongNavigator(Game a_game, Graph a_graph)
    {
        MAX_NODES =  a_game.getWaypoints().size();
        m_graph = a_graph;
        m_nodes = new TreeMap<Integer, Vector2d>();
        m_dists = new double[MAX_NODES][MAX_NODES];
        m_distOrigin = new double[MAX_NODES];
        m_paths = new Path[MAX_NODES][MAX_NODES];

        int index = 0;
        for(Waypoint way: a_game.getWaypoints())        //Add all waypoints to the path.
        {
            m_nodes.put(index++, way.s.copy());
        }

        //Precompute distances between all waypoints.
        for(int i = 0; i < m_nodes.size(); ++i)
        {
            Vector2d a1 = m_nodes.get(i);
            for(int j = 0; j < m_nodes.size(); ++j)
            {
                if(i > j)
                {
                    Vector2d a2 = m_nodes.get(j);
                    m_paths[i][j] = getPath(a1, a2);
                    double distance = m_paths[i][j].m_cost;
                    m_paths[j][i] = getPath(a2, a1);  //we need both directions, but it's symmetric.

                    m_dists[i][j] = distance;
                    m_dists[j][i] = distance;

                }else if(i == j){
                    m_dists[i][i] = Double.MAX_VALUE;
                }
            }
        }

        //Precompute distances from starting position to all waypoints.
        Vector2d startingPoint = a_game.getMap().getStartingPoint();
        for(int i = 0; i < m_nodes.size(); ++i)
        {
            Vector2d a1 = m_nodes.get(i);
            double distance = getDistance(startingPoint, a1);//a1.dist(startingPoint);
            m_distOrigin[i] = distance;
        }

    }