Class Node
java.lang.Object
topics.branchandbound.util.Node
- All Implemented Interfaces:
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidintbooleanCompares whether two nodes are equal using the ToString methodexpand()intgetDepth()Getter for depthintGetter for heuristicValuegetID()Gets the ID of the nodeGetter for parentIDintWe can have extra information about the problem to prune all the nodes above a specific heuristicValue.abstract boolean
-
Field Details
-
ID
-
parentID
-
depth
protected int depth -
heuristicValue
protected int heuristicValue
-
-
Constructor Details
-
Node
public Node()Constructor for Node objects
-
-
Method Details
-
getID
-
getParentID
-
getDepth
public int getDepth()Getter for depth- Returns:
- The depth variable
-
getHeuristicValue
public int getHeuristicValue()Getter for heuristicValue- Returns:
- The heuristicValue variable
-
equals
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
- Specified by:
compareToin interfaceComparable<Node>
-
calculateHeuristicValue
public abstract void calculateHeuristicValue() -
expand
-
isSolution
public abstract boolean isSolution()
-