Class InterleavingNode

java.lang.Object
topics.branchandbound.utils.Node
topics.branchandbound.stringinterleaving.InterleavingNode
All Implemented Interfaces:
Comparable<Node>

public class InterleavingNode extends Node

State Node for String Interleaving

Represents a single point in the state space tree. Since we are using a Priority Queue (Heap) in Branch and Bound, each node must be an immutable snapshot of the current interleaving process.

Author:
vicegd
  • Constructor Details

    • InterleavingNode

      public InterleavingNode(String a, String b)
      Root Node Constructor.
    • InterleavingNode

      public InterleavingNode(InterleavingNode parent, String newInterleaving, int posA, int posB)
      Child Node Constructor.
  • Method Details

    • calculateHeuristicValue

      public void calculateHeuristicValue()
      Heuristic: Distance to completion. Since Heap extracts the minimum value first, negative values representing shallow nodes will be extracted first, forcing a Breadth-First Search (BFS) behavior.
      Specified by:
      calculateHeuristicValue in class Node
    • expand

      public ArrayList<Node> expand()
      Description copied from class: Node
      Generates all mathematically valid state configurations extending from this specific topological juncture.
      Specified by:
      expand in class Node
      Returns:
      A list containing the resulting child nodes.
    • isSolution

      public boolean isSolution()
      Description copied from class: Node
      Determines whether the current node represents a fully resolved configuration satisfying all problem constraints.
      Specified by:
      isSolution in class Node
      Returns:
      true if the state is a complete mathematical solution; false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object