Class SNTGraph<V,E extends org.jgrapht.graph.DefaultWeightedEdge>

java.lang.Object
org.jgrapht.graph.AbstractGraph<V,E>
org.jgrapht.graph.AbstractBaseGraph<V,E>
sc.fiji.snt.analysis.graph.SNTGraph<V,E>
Type Parameters:
V - the vertex type
E - the edge type, must extend DefaultWeightedEdge
All Implemented Interfaces:
Serializable, Cloneable, org.jgrapht.Graph<V,E>
Direct Known Subclasses:
AnnotationGraph, DirectedWeightedGraph, SNTPseudograph

public abstract class SNTGraph<V,E extends org.jgrapht.graph.DefaultWeightedEdge> extends org.jgrapht.graph.AbstractBaseGraph<V,E>
An abstract weighted graph implementation that extends AbstractBaseGraph with additional support for vertex/edge coloring and vertex value mapping. This specialized graph implementation is designed for visualization and analysis purposes in Graph Viewer.

The graph maintains three main mappings:

  • Vertex colors - Associates vertices with RGB colors
  • Edge colors - Associates edges with RGB colors
  • Vertex values - Associates vertices with numeric values

This implementation also provides methods for filtering and transforming vertices and edges.

See Also:
  • Field Summary

    Fields inherited from interface org.jgrapht.Graph

    DEFAULT_EDGE_WEIGHT
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SNTGraph(Supplier<V> vertexSupplier, Supplier<E> edgeSupplier, org.jgrapht.GraphType type)
     
    protected
    SNTGraph(Supplier<V> vertexSupplier, Supplier<E> edgeSupplier, org.jgrapht.GraphType type, org.jgrapht.graph.GraphSpecificsStrategy<V,E> specificsStrategy)
    Variant constructor that lets a subclass pick a custom GraphSpecificsStrategy: e.g. a CSR-backed implementation to keep memory usage proportional to (V+E) rather than to the per-vertex object overhead jgrapht's default strategies use.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Apply the given operator over the edge set.
    void
    Apply the given operator over the vertex set.
    void
    filterEdges(Predicate<E> predicate)
    Remove edges from this graph that do not match the given predicate.
    void
    Remove vertices from this graph that do not match the given predicate.
    org.scijava.util.ColorRGB
     
    Map<E,org.scijava.util.ColorRGB>
     
    org.scijava.util.ColorRGB
    getVertexColor(V vertex)
     
    Map<V,org.scijava.util.ColorRGB>
     
    double
    getVertexValue(V vertex)
     
     
    void
    setEdgeColor(E edge, org.scijava.util.ColorRGB color)
     
    void
    setVertexColor(V vertex, org.scijava.util.ColorRGB color)
     
    void
    setVertexValue(V vertex, double value)
     

    Methods inherited from class org.jgrapht.graph.AbstractBaseGraph

    addEdge, addEdge, addVertex, addVertex, clone, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, iterables, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeSupplier, setEdgeWeight, setVertexSupplier, vertexSet

    Methods inherited from class org.jgrapht.graph.AbstractGraph

    assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jgrapht.Graph

    containsEdge, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight
  • Constructor Details

    • SNTGraph

      protected SNTGraph(Supplier<V> vertexSupplier, Supplier<E> edgeSupplier, org.jgrapht.GraphType type)
    • SNTGraph

      protected SNTGraph(Supplier<V> vertexSupplier, Supplier<E> edgeSupplier, org.jgrapht.GraphType type, org.jgrapht.graph.GraphSpecificsStrategy<V,E> specificsStrategy)
      Variant constructor that lets a subclass pick a custom GraphSpecificsStrategy: e.g. a CSR-backed implementation to keep memory usage proportional to (V+E) rather than to the per-vertex object overhead jgrapht's default strategies use. The default 3-arg constructor continues to inherit jgrapht's defaults; subclasses that don't need specialized storage should keep using it.
      See Also:
  • Method Details

    • setVertexColor

      public void setVertexColor(V vertex, org.scijava.util.ColorRGB color)
    • setEdgeColor

      public void setEdgeColor(E edge, org.scijava.util.ColorRGB color)
    • getVertexColor

      public org.scijava.util.ColorRGB getVertexColor(V vertex)
    • getEdgeColor

      public org.scijava.util.ColorRGB getEdgeColor(E edge)
    • setVertexValue

      public void setVertexValue(V vertex, double value)
    • getVertexValue

      public double getVertexValue(V vertex)
    • getVertexColorRGBMap

      public Map<V,org.scijava.util.ColorRGB> getVertexColorRGBMap()
    • getEdgeColorRGBMap

      public Map<E,org.scijava.util.ColorRGB> getEdgeColorRGBMap()
    • getVertexValueMap

      public Map<V,Double> getVertexValueMap()
    • filterVertices

      public void filterVertices(Predicate<V> predicate)
      Remove vertices from this graph that do not match the given predicate. Edges incident to removed vertices are also removed from the graph.
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each vertex to determine if it should be retained in the vertex set.
    • filterEdges

      public void filterEdges(Predicate<E> predicate)
      Remove edges from this graph that do not match the given predicate. Vertices incident to removed edges are _not_ removed from the graph.
      Parameters:
      predicate - a non-interfering, stateless predicate to apply to each edge to determine if it should be retained in the edge set.
    • applyVertices

      public void applyVertices(UnaryOperator<V> operator)
      Apply the given operator over the vertex set. If a vertex is changed as a result of the function (on the basis of equality, e.g., vIn.equals(vOut)), the input vertex is replaced with the output vertex and all neighboring edges of the input vertex are re-assigned to the output vertex. If the output vertex is null, the input vertex and its neighboring edges are removed from the graph.
      Parameters:
      operator - a non-interfering, stateless operator to apply to each vertex
    • applyEdges

      public void applyEdges(UnaryOperator<E> operator)
      Apply the given operator over the edge set. If an edge is changed as a result of the function (on the basis of equality, e.g., edgeIn.equals(edgeOut)), the input edge between source and target is replaced with the output edge. If the output edge is null, the input edge is removed from the graph.
      Parameters:
      operator - a non-interfering, stateless operator to apply to each edge