Class ReduceObjectsGraph

Object
ReduceObjectsGraph

public class ReduceObjectsGraph extends Object
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 Details

  • Method Details

    • isEmpty

      public boolean isEmpty()
      Do no elements exist?
      Returns:
      true if no elemenets exist, false if at least one element exists.
    • peek

      public ObjectForReduction peek()
      The element at the top of the queue, returned without modifying the queue.
      Returns:
      the highest-priority element
    • poll

      public ObjectForReduction poll()
      The element at the top of the queue, returned removing it from the queue and graph.
      Returns:
      the highest-priority element.
    • adjacentVerticesOutgoing

      public List<ObjectForReduction> adjacentVerticesOutgoing(ObjectForReduction vertex)
      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

      public Stream<ObjectForReduction> adjacentVerticesOutgoingStream(ObjectForReduction vertex)
      Parameters:
      vertex - the vertex to find adjacent vertices for.
      Returns:
      all vertices to which an outgoing edge exists from vertex.
    • removeEdge

      public void removeEdge(ObjectForReduction from, ObjectForReduction to)
      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 and to.

      Parameters:
      from - the vertex the edge joins from.
      to - the vertex the edge joins to.
    • removeVertex

      public void removeVertex(ObjectForReduction vertex) throws OperationFailedException
      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 replaces element1 and element2.