Class Node

java.lang.Object
topics.branchandbound.util.Node
All Implemented Interfaces:
Comparable<Node>

public abstract class Node extends Object implements Comparable<Node>
To represent the different states of a problem in the graph For each problem, we should extend this class with specific information We also need to compare Nodes because it is the way to compare them in the priority queue
Author:
vicegd
  • Field Details

    • ID

      protected UUID ID
    • parentID

      protected UUID parentID
    • depth

      protected int depth
    • heuristicValue

      protected int heuristicValue
  • Constructor Details

    • Node

      public Node()
      Constructor for Node objects
  • Method Details

    • getID

      public UUID getID()
      Gets the ID of the node
      Returns:
      ID of the node
    • getParentID

      public UUID getParentID()
      Getter for parentID
      Returns:
      The parentID variable
    • getDepth

      public int getDepth()
      Getter for depth
      Returns:
      The depth variable
    • getHeuristicValue

      public int getHeuristicValue()
      Getter for heuristicValue
      Returns:
      The heuristicValue variable
    • equals

      public boolean equals(Node n)
      Compares whether two nodes are equal using the ToString method
      Parameters:
      n - Another node to be compared with
      Returns:
      True if there are equal. False otherwise
    • initialValuePruneLimit

      public int initialValuePruneLimit()
      We can have extra information about the problem to prune all the nodes above a specific heuristicValue. By default we know nothing, so we do not prune anything
      Returns:
      Value of the initial prune limit
    • compareTo

      public int compareTo(Node node)
      Specified by:
      compareTo in interface Comparable<Node>
    • calculateHeuristicValue

      public abstract void calculateHeuristicValue()
    • expand

      public abstract ArrayList<Node> expand()
    • isSolution

      public abstract boolean isSolution()