V
 the vertex typeE
 the edge typeG
 the type of the base graphAsSubgraph
.@Deprecated public class Subgraph<V,E,G extends Graph<V,E>> extends AsSubgraph<V,E> implements Serializable
Graph
interface.
If the base graph is a ListenableGraph
, the subgraph listens on the base
graph and guarantees the subgraph property. If an edge or a vertex is removed from the base
graph, it is automatically removed from the subgraph. Subgraph listeners are informed on such
removal only if it results in a cascaded removal from the subgraph. If the subgraph has been
created as an induced subgraph it also keeps track of edges being added to its vertices. If
vertices are added to the base graph, the subgraph remains unaffected.
If the base graph is not a ListenableGraph, then the subgraph property cannot be guaranteed. If edges or vertices are removed from the base graph, they are not removed from the subgraph.
Modifications to Subgraph are allowed as long as the subgraph property is maintained. Addition of vertices or edges are allowed as long as they also exist in the base graph. Removal of vertices or edges is always allowed. The base graph is never affected by any modification made to the subgraph.
A subgraph may provide a "livewindow" on a base graph, so that changes made to its vertices or
edges are immediately reflected in the base graph, and vice versa. For that to happen, vertices
and edges added to the subgraph must be identical (that is, referenceequal and not only
valueequal) to their respective ones in the base graph. Previous versions of this class enforced
such identity, at a severe performance cost. Currently it is no longer enforced. If you want to
achieve a "livewindow" functionality, your safest tactics would be to NOT override the
equals()
methods of your vertices and edges. If you use a class that has already
overridden the equals()
method, such as String
, than you can use a
wrapper around it, or else use it directly but exercise a great care to avoid having
differentbutequal instances in the subgraph and the base graph.
This graph implementation guarantees deterministic vertex and edge set ordering (via
LinkedHashSet
).
Note that this implementation tries to maintain a "livewindow" on the base graph, which has implications in the performance of the various operations. For example iterating over the adjacent edges of a vertex takes time proportional to the number of adjacent edges of the vertex in the base graph even if the subgraph contains only a small subset of those edges. Therefore, the user must be aware that using this implementation for certain algorithms might come with computational overhead. For certain algorithms it is better to maintain a subgraph by hand instead of using this implementation as a black box.
Graph
,
Set
,
Serialized FormModifier and Type  Field and Description 

protected G 
g
Deprecated.

base, baseType, edgeSet, isInduced, vertexSet
DEFAULT_EDGE_WEIGHT
Constructor and Description 

Subgraph(G base)
Deprecated.
Creates a new induced Subgraph with all vertices included.

Subgraph(G base,
Set<? extends V> vertexSubset)
Deprecated.
Creates a new induced Subgraph.

Subgraph(G base,
Set<? extends V> vertexSubset,
Set<? extends E> edgeSubset)
Deprecated.
Creates a new Subgraph.

Modifier and Type  Method and Description 

G 
getBase()
Deprecated.
Get the base graph.

addEdge, addEdge, addVertex, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, getType, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeWeight, vertexSet
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toString, toStringFromSets
public Subgraph(G base, Set<? extends V> vertexSubset, Set<? extends E> edgeSubset)
base
 the base (backing) graph on which the subgraph will be based.vertexSubset
 vertices to include in the subgraph. If null
then all
vertices are included.edgeSubset
 edges to in include in the subgraph. If null
then all the
edges whose vertices found in the graph are included.public Subgraph(G base, Set<? extends V> vertexSubset)
base
 the base (backing) graph on which the subgraph will be based.vertexSubset
 vertices to include in the subgraph. If null
then all
vertices are included.public Subgraph(G base)
base
 the base (backing) graph on which the subgraph will be based.public G getBase()
Copyright © 2017. All rights reserved.