Class ReduceObjectsGraph
Object
ReduceObjectsGraph
Combines a
PriorityQueue
(ordering by highest confidence) and a graph-structure
indicating which objects overlap with each other.
Any operation that changes one structure, will also update the other structure.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionReduceObjectsGraph
(List<LabelledWithConfidence<ObjectMask>> elements) Create with a list of elements. -
Method Summary
Modifier and TypeMethodDescriptionThe vertices that are connected to a particular vertex by an outgoing edge.LikeadjacentVerticesOutgoing(org.anchoranalysis.image.inference.bean.reduce.ObjectForReduction)
but returns aStream
instead of aSet
.boolean
isEmpty()
Do no elements exist?void
mergeVertices
(ObjectForReduction element1, ObjectForReduction element2, ObjectForReduction merged) Merges two existing vertices together.peek()
The element at the top of the queue, returned without modifying the queue.poll()
The element at the top of the queue, returned removing it from the queue and graph.void
removeEdge
(ObjectForReduction from, ObjectForReduction to) Remove an edge between two vertices.void
removeVertex
(ObjectForReduction vertex) Removes a vertex and any edges connected to it.
-
Constructor Details
-
ReduceObjectsGraph
Create with a list of elements.- Parameters:
elements
- the elements.
-
-
Method Details
-
isEmpty
public boolean isEmpty()Do no elements exist?- Returns:
- true if no elemenets exist, false if at least one element exists.
-
peek
The element at the top of the queue, returned without modifying the queue.- Returns:
- the highest-priority element
-
poll
The element at the top of the queue, returned removing it from the queue and graph.- Returns:
- the highest-priority element.
-
adjacentVerticesOutgoing
The vertices that are connected to a particular vertex by an outgoing edge.- Parameters:
vertex
- the vertex to find adjacent vertices for.- Returns:
- all vertices to which an outgoing edge exists from
vertex
.
-
adjacentVerticesOutgoingStream
LikeadjacentVerticesOutgoing(org.anchoranalysis.image.inference.bean.reduce.ObjectForReduction)
but returns aStream
instead of aSet
.- Parameters:
vertex
- the vertex to find adjacent vertices for.- Returns:
- all vertices to which an outgoing edge exists from
vertex
.
-
removeEdge
Remove an edge between two vertices.For an undirected graph, the directionality is irrelevant, and will achieve the same effect, whatever the order of
from
andto
.- Parameters:
from
- the vertex the edge joins from.to
- the vertex the edge joins to.
-
removeVertex
Removes a vertex and any edges connected to it.- Parameters:
vertex
- the vertex to remove- Throws:
OperationFailedException
- if the vertex doesn't exist in the graph.
-
mergeVertices
public void mergeVertices(ObjectForReduction element1, ObjectForReduction element2, ObjectForReduction merged) Merges two existing vertices together.The two existing vertices are replaced with
merged
.Existing incoming and outgoing edges for the two vertices are then connected instead to
merged
.- Parameters:
element1
- the first element to merge.element2
- the second element to merge.merged
- the merged element that replaceselement1
andelement2
.
-