public class ReduceObjectsGraph extends Object
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.
Constructor and Description |
---|
ReduceObjectsGraph(List<LabelledWithConfidence<ObjectMask>> elements)
Create with a list of elements.
|
Modifier and Type | Method and Description |
---|---|
List<ObjectForReduction> |
adjacentVerticesOutgoing(ObjectForReduction vertex)
The vertices that are connected to a particular vertex by an outgoing edge.
|
java.util.stream.Stream<ObjectForReduction> |
adjacentVerticesOutgoingStream(ObjectForReduction vertex)
Like
adjacentVerticesOutgoing(org.anchoranalysis.image.inference.bean.reduce.ObjectForReduction) but returns a Stream instead of a Set . |
boolean |
isEmpty()
Do no elements exist?
|
void |
mergeVertices(ObjectForReduction element1,
ObjectForReduction element2,
ObjectForReduction merged)
Merges two existing vertices together.
|
ObjectForReduction |
peek()
The element at the top of the queue, returned without modifying the queue.
|
ObjectForReduction |
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.
|
public ReduceObjectsGraph(List<LabelledWithConfidence<ObjectMask>> elements)
elements
- the elements.public boolean isEmpty()
public ObjectForReduction peek()
public ObjectForReduction poll()
public List<ObjectForReduction> adjacentVerticesOutgoing(ObjectForReduction vertex)
vertex
- the vertex to find adjacent vertices for.vertex
.public java.util.stream.Stream<ObjectForReduction> adjacentVerticesOutgoingStream(ObjectForReduction vertex)
adjacentVerticesOutgoing(org.anchoranalysis.image.inference.bean.reduce.ObjectForReduction)
but returns a Stream
instead of a Set
.vertex
- the vertex to find adjacent vertices for.vertex
.public void removeEdge(ObjectForReduction from, ObjectForReduction to)
For an undirected graph, the directionality is irrelevant, and will achieve the same
effect, whatever the order of from
and to
.
from
- the vertex the edge joins from.to
- the vertex the edge joins to.public void removeVertex(ObjectForReduction vertex) throws OperationFailedException
vertex
- the vertex to removeOperationFailedException
- if the vertex doesn't exist in the graph.public void mergeVertices(ObjectForReduction element1, ObjectForReduction element2, ObjectForReduction merged)
The two existing vertices are replaced with merged
.
Existing incoming and outgoing edges for the two vertices are then connected instead to
merged
.
element1
- the first element to merge.element2
- the second element to merge.merged
- the merged element that replaces element1
and element2
.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.