Class MergeGraph
Object
MergeGraph
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 Summary
ConstructorsConstructorDescriptionMergeGraph(PayloadCalculator payloadCalculator, UpdatableBeforeCondition beforeCondition, Optional<UnitConverter> unitConverter, AssignPriority prioritizer, Logger logger, boolean logPayload) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddObjectsToGraph(ObjectCollection objects) Adds objects to the graph.Finds the edge with the maximum priority for merging.voidLogs a description of the current graph state.merge(TypedEdge<ObjectVertex, PrioritisedVertex> bestImprovement) Merges two vertices in the graph.Retrieves all vertices in the graph as anObjectCollection.
-
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 objectbeforeCondition- condition to check before mergingunitConverter- converts units from voxels to physical measurements and vice-versaprioritizer- means to assign priority to the merge of any two objectslogger- logger for outputting messageslogPayload- 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- theObjectCollectionto add- Returns:
- a list of
ObjectVertexobjects created from the input objects - Throws:
OperationFailedException- if the operation fails
-
merge
public ObjectVertex merge(TypedEdge<ObjectVertex, PrioritisedVertex> bestImprovement) throws OperationFailedExceptionMerges 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
Finds the edge with the maximum priority for merging.- Returns:
- the
TypedEdgewith the highest priority, or null if no valid edges exist
-
logGraphDescription
public void logGraphDescription()Logs a description of the current graph state. -
verticesAsObjects
Retrieves all vertices in the graph as anObjectCollection.- Returns:
- an
ObjectCollectioncontaining all objects in the graph
-