Package sc.fiji.snt.analysis.graph
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 typeE- the edge type, must extendDefaultWeightedEdge
- 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
ConstructorsModifierConstructorDescriptionprotectedprotectedSNTGraph(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 customGraphSpecificsStrategy: 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 TypeMethodDescriptionvoidapplyEdges(UnaryOperator<E> operator) Apply the given operator over the edge set.voidapplyVertices(UnaryOperator<V> operator) Apply the given operator over the vertex set.voidfilterEdges(Predicate<E> predicate) Remove edges from this graph that do not match the given predicate.voidfilterVertices(Predicate<V> predicate) Remove vertices from this graph that do not match the given predicate.org.scijava.util.ColorRGBgetEdgeColor(E edge) org.scijava.util.ColorRGBgetVertexColor(V vertex) doublegetVertexValue(V vertex) voidsetEdgeColor(E edge, org.scijava.util.ColorRGB color) voidsetVertexColor(V vertex, org.scijava.util.ColorRGB color) voidsetVertexValue(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, vertexSetMethods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSetsMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jgrapht.Graph
containsEdge, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight
-
Constructor Details
-
SNTGraph
-
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 customGraphSpecificsStrategy: 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
-
setEdgeColor
-
getVertexColor
-
getEdgeColor
-
setVertexValue
-
getVertexValue
-
getVertexColorRGBMap
-
getEdgeColorRGBMap
-
getVertexValueMap
-
filterVertices
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
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
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
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
-