Class MergeGraph

Object
MergeGraph

public class MergeGraph extends Object
A graph that stores each object as a vertex, where edges represent a neighborhood relation.

It potentially allows merges between neighboring vertices.

Each vertex has a payload (double) value associated with it, that is a function of the object-mask.

  • Constructor Details

    • MergeGraph

      public MergeGraph(PayloadCalculator payloadCalculator, UpdatableBeforeCondition beforeCondition, Optional<UnitConverter> unitConverter, AssignPriority prioritizer, Logger logger, boolean logPayload)
      Constructor.
      Parameters:
      payloadCalculator - means to calculate a payload for any object
      beforeCondition - condition to check before merging
      unitConverter - converts units from voxels to physical measurements and vice-versa
      prioritizer - means to assign priority to the merge of any two objects
      logger - logger for outputting messages
      logPayload - whether to include the payload in logging messages
  • Method Details

    • addObjectsToGraph

      public List<ObjectVertex> addObjectsToGraph(ObjectCollection objects) throws OperationFailedException
      Adds objects to the graph.
      Parameters:
      objects - the ObjectCollection to add
      Returns:
      a list of ObjectVertex objects created from the input objects
      Throws:
      OperationFailedException - if the operation fails
    • merge

      public ObjectVertex merge(TypedEdge<ObjectVertex, PrioritisedVertex> bestImprovement) throws OperationFailedException
      Merges two vertices in the graph.
      Parameters:
      bestImprovement - the edge representing the best merge improvement
      Returns:
      the newly created merged ObjectVertex
      Throws:
      OperationFailedException - if the merge operation fails
    • findMaxPriority

      public TypedEdge<ObjectVertex, PrioritisedVertex> findMaxPriority()
      Finds the edge with the maximum priority for merging.
      Returns:
      the TypedEdge with the highest priority, or null if no valid edges exist
    • logGraphDescription

      public void logGraphDescription()
      Logs a description of the current graph state.
    • verticesAsObjects

      public ObjectCollection verticesAsObjects()
      Retrieves all vertices in the graph as an ObjectCollection.
      Returns:
      an ObjectCollection containing all objects in the graph