Exemple #1
0
    /// <summary>
    /// Find the shortest path between two nodes
    /// </summary>
    /// <param name="start">Starting Node</param>
    /// <param name="end">End node</param>
    /// <returns> List of nodes in order of shortest path</returns>
    public List <NavNode> FindPath(NavNode start, NavNode end)
    {
        //the end node in the path
        NavNode endNode = DijkstraPathfinding(start, end);

        //Create path by traversing parents from end node
        List <NavNode> result = new List <NavNode>();

        while (endNode.GetParentSet())
        {
            result.Add(endNode);
            endNode = endNode.GetParentNode();
        }

        //Reverse the path
        result.Reverse();
        return(result);
    }