Ejemplo n.º 1
0
        /// <summary>Gets and returns the successors or predecessors of the given node, omitting paths that correspond to
        /// previously visited states and are not better than the existing path.
        /// </summary>
        /// <param name="parent">The state whose successors or predecessors will be returned.</param>
        /// <param name="statesSeen">A dictionary mapping states to the best known path to that state, or null if
        /// <see cref="GraphSearchBase{S,A}.EliminateDuplicateStates"/> is false.
        /// </param>
        /// <param name="reversed">If true, the predecessors of the node will be retrieved. If false, the successors.</param>
        /// <returns>Returns the new nodes to add to the queue.</returns>
        IEnumerable <Node <StateType, ActionType> > GetNodes(Node <StateType, ActionType> parent,
                                                             Dictionary <StateType, Node <StateType, ActionType> > statesSeen,
                                                             bool reversed)
        {
            IEnumerable <StateActionPair <StateType, ActionType> > statePairs =
                reversed ? BidiProblem.GetPredecessors(parent.State) : Problem.GetSuccessors(parent.State);

            return(statesSeen == null?GetNodes(parent, statePairs)
                       : GetNonDuplicatedNodes(parent, statePairs, statesSeen));
        }