AIMA.Core.Search.Framework.GraphSearch.getResultingNodesToAddToFrontier C# (CSharp) Method

getResultingNodesToAddToFrontier() public method

public getResultingNodesToAddToFrontier ( Node nodeToExpand, Problem problem ) : List
nodeToExpand Node
problem Problem
return List
        public override List<Node> getResultingNodesToAddToFrontier(Node nodeToExpand,
                Problem problem)
        {

            addToFrontier.Clear();
            // add the node to the explored set
            explored.Add(nodeToExpand.getState());
            // expand the chosen node, adding the resulting nodes to the frontier
            foreach (Node cfn in expandNode(nodeToExpand, problem))
            {
                Node frontierNode = frontierState[cfn.getState()];
                bool yesAddToFrontier = false;
                // only if not in the frontier or explored set
                if (null == frontierNode && !explored.Contains(cfn.getState()))
                {
                    yesAddToFrontier = true;
                }
                else if (null != frontierNode
                      && null != replaceFrontierNodeAtStateCostFunction
                      && replaceFrontierNodeAtStateCostFunction.Compare(cfn,
                              frontierNode) < 0)
                {
                    // child.STATE is in frontier with higher cost
                    // replace that frontier node with child
                    yesAddToFrontier = true;
                    // Want to replace the current frontier node with the child
                    // node therefore mark the child to be added and remove the
                    // current fontierNode
                    removeNodeFromFrontier(frontierNode);
                    // Ensure removed from add to frontier as well
                    // as 1 or more may reach the same state at the same time
                    addToFrontier.Remove(frontierNode);
                }

                if (yesAddToFrontier)
                {
                    addToFrontier.Add(cfn);
                    frontierState.Add(cfn.getState(), cfn);
                }
            }

            return addToFrontier;
        }
    }