Class Node


  • public class Node
    extends Object
    A node is a value to process in the BFS. It also links children to parents to ensure hierarchy in variables.
    • Constructor Detail

      • Node

        public Node​(Node.NodeValue value,
                    Node.IParent parent)
        Create a new node for the BFS.
        Parameters:
        value - the value to wrap
        parent - the parent of this node
      • Node

        public Node​(Node.NodeValue value,
                    Set<Node> children,
                    Node.IParent parent)
        Create a new node for the BFS.
        Parameters:
        value - the value to wrap
        children - the children of this node
        parent - the parent of this node
    • Method Detail

      • breadthFirstSearch

        public static void breadthFirstSearch​(Node root,
                                              Node.IConsumer consumer)
        Start the breadth first search of the nodes.
        Parameters:
        root - the root node to start from
        consumer - the consumer to use to collect more nodes.
      • addChildren

        public void addChildren​(Set<Node> children)
        Add child nodes.
        Parameters:
        children - the children to add
      • depth

        public int depth()