- java.lang.Object
-
- org.jgrapht.graph.AbstractGraph<V,E>
-
- org.jgrapht.graph.GraphDelegator<V,E>
-
- org.jgrapht.graph.ParanoidGraph<V,E>
-
- Type Parameters:
V
- the graph vertex typeE
- the graph edge type
- All Implemented Interfaces:
Serializable
,Graph<V,E>
public class ParanoidGraph<V,E> extends GraphDelegator<V,E>
ParanoidGraph provides a way to verify that objects added to a graph obey the standard equals/hashCode contract. It can be used to wrap an underlying graph to be verified. Note that the verification is very expensive, so ParanoidGraph should only be used during debugging.- Author:
- John Sichi
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jgrapht.Graph
DEFAULT_EDGE_WEIGHT
-
-
Constructor Summary
Constructors Constructor Description ParanoidGraph(Graph<V,E> g)
Create a new paranoid graph.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(V sourceVertex, V targetVertex, E e)
Adds the specified edge to this graph, going from the source vertex to the target vertex.boolean
addVertex(V v)
Adds the specified vertex to this graph if not already present.-
Methods inherited from class org.jgrapht.graph.GraphDelegator
addEdge, addVertex, containsEdge, containsVertex, degreeOf, edgeSet, edgesOf, getAllEdges, getDelegate, getEdge, getEdgeSource, getEdgeSupplier, getEdgeTarget, getEdgeWeight, getType, getVertexSupplier, incomingEdgesOf, inDegreeOf, outDegreeOf, outgoingEdgesOf, removeEdge, removeEdge, removeVertex, setEdgeWeight, toString, vertexSet
-
Methods inherited from class org.jgrapht.graph.AbstractGraph
assertVertexExist, containsEdge, equals, hashCode, removeAllEdges, removeAllEdges, removeAllEdges, removeAllVertices, toStringFromSets
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jgrapht.Graph
containsEdge, iterables, removeAllEdges, removeAllEdges, removeAllVertices, setEdgeWeight
-
-
-
-
Method Detail
-
addEdge
public boolean addEdge(V sourceVertex, V targetVertex, E e)
Adds the specified edge to this graph, going from the source vertex to the target vertex. More formally, adds the specified edge,e
, to this graph if this graph contains no edgee2
such thate2.equals(e)
. If this graph already contains such an edge, the call leaves this graph unchanged and returnsfalse
. Some graphs do not allow edge-multiplicity. In such cases, if the graph already contains an edge from the specified source to the specified target, then this method does not change the graph and returnsfalse
. If the edge was added to the graph, returnstrue
.- Specified by:
addEdge
in interfaceGraph<V,E>
- Overrides:
addEdge
in classGraphDelegator<V,E>
- Parameters:
sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.e
- edge to be added to this graph.- Returns:
true
if this graph did not already contain the specified edge.- See Also:
Graph.addEdge(Object, Object)
,Graph.getEdgeSupplier()
-
addVertex
public boolean addVertex(V v)
Adds the specified vertex to this graph if not already present. More formally, adds the specified vertex,v
, to this graph if this graph contains no vertexu
such thatu.equals(v)
. If this graph already contains such vertex, the call leaves this graph unchanged and returnsfalse
. In combination with the restriction on constructors, this ensures that graphs never contain duplicate vertices.
-
-