Пример #1
0
            // methods
            #region private static Stepper<T> Greedy_BuildPath(Greedy_Node node)
            /// <summary>Builds the path from resulting from the A* algorithm.</summary>
            /// <param name="node">The resulting final node fromt he A* algorithm.</param>
            /// <returns>A stepper function of the computed path frmo the A* algorithm.</returns>
            private static Stepper <T> Greedy_BuildPath(Greedy_Node node)
            {
                Greedy_PathNode end;
                Greedy_PathNode start = Greedy_BuildPath(node, out end);

                return((Step <T> step) =>
                {
                    Greedy_PathNode current = start;
                    while (current != null)
                    {
                        step(current.Value);
                        current = current.Next;
                    }
                });
            }
Пример #2
0
 private static Greedy_PathNode Greedy_BuildPath(Greedy_Node currentNode, out Greedy_PathNode currentPathNode)
 {
     if (currentNode.Previous == null)
     {
         Greedy_PathNode start = new Greedy_PathNode(currentNode.Value);
         currentPathNode = start;
         return(start);
     }
     else
     {
         Greedy_PathNode previous;
         Greedy_PathNode start = Greedy_BuildPath(currentNode.Previous, out previous);
         currentPathNode = new Greedy_PathNode(currentNode.Value);
         previous.Next   = currentPathNode;
         return(start);
     }
 }