|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgrapht.graph.AbstractGraph<V,E>
public abstract class AbstractGraph<V,E>
A skeletal implementation of the Graph interface, to minimize the effort required to implement graph interfaces. This implementation is applicable to both: directed graphs and undirected graphs.
Graph
,
DirectedGraph
,
UndirectedGraph
Constructor Summary | |
---|---|
AbstractGraph()
Construct a new empty graph object. |
Method Summary | |
---|---|
protected boolean |
assertVertexExist(V v)
Ensures that the specified vertex exists in this graph, or else throws exception. |
boolean |
containsEdge(V sourceVertex,
V targetVertex)
Returns true if and only if this graph contains an edge going from the source vertex to the target vertex. |
boolean |
removeAllEdges(java.util.Collection<? extends E> edges)
Removes all the edges in this graph that are also contained in the specified edge collection. |
protected boolean |
removeAllEdges(E[] edges)
Removes all the edges in this graph that are also contained in the specified edge array. |
java.util.Set<E> |
removeAllEdges(V sourceVertex,
V targetVertex)
Removes all the edges going from the specified source vertex to the specified target vertex, and returns a set of all removed edges. |
boolean |
removeAllVertices(java.util.Collection<? extends V> vertices)
Removes all the vertices in this graph that are also contained in the specified vertex collection. |
java.lang.String |
toString()
Returns a string of the parenthesized pair (V, E) representing this G=(V,E) graph. |
protected java.lang.String |
toStringFromSets(java.util.Collection<? extends V> vertexSet,
java.util.Collection<? extends E> edgeSet,
boolean directed)
Helper for subclass implementations of toString( ). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.jgrapht.Graph |
---|
addEdge, addEdge, addVertex, containsEdge, containsVertex, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, removeEdge, removeEdge, removeVertex, vertexSet |
Constructor Detail |
---|
public AbstractGraph()
Method Detail |
---|
public boolean containsEdge(V sourceVertex, V targetVertex)
Graph
null
, returns false
.
containsEdge
in interface Graph<V,E>
sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.
Graph.containsEdge(Object, Object)
public boolean removeAllEdges(java.util.Collection<? extends E> edges)
Graph
Graph.removeEdge(Object)
method.
removeAllEdges
in interface Graph<V,E>
edges
- edges to be removed from this graph.
Graph.removeAllEdges(Collection)
public java.util.Set<E> removeAllEdges(V sourceVertex, V targetVertex)
Graph
null
if any of the specified vertices does not exist in the
graph. If both vertices exist but no edge is found, returns an empty set.
This method will either invoke the Graph.removeEdge(Object)
method, or
the Graph.removeEdge(Object, Object)
method.
removeAllEdges
in interface Graph<V,E>
sourceVertex
- source vertex of the edge.targetVertex
- target vertex of the edge.
null
if no either vertex not
part of graphGraph.removeAllEdges(Object, Object)
public boolean removeAllVertices(java.util.Collection<? extends V> vertices)
Graph
Graph.removeVertex(Object)
method.
removeAllVertices
in interface Graph<V,E>
vertices
- vertices to be removed from this graph.
Graph.removeAllVertices(Collection)
public java.lang.String toString()
toString
in class java.lang.Object
protected boolean assertVertexExist(V v)
v
- vertex
true
if this assertion holds.
java.lang.NullPointerException
- if specified vertex is null
.
java.lang.IllegalArgumentException
- if specified vertex does not exist in
this graph.protected boolean removeAllEdges(E[] edges)
Graph.removeEdge(Object)
method.
edges
- edges to be removed from this graph.
Graph.removeEdge(Object)
,
Graph.containsEdge(Object)
protected java.lang.String toStringFromSets(java.util.Collection<? extends V> vertexSet, java.util.Collection<? extends E> edgeSet, boolean directed)
vertexSet
- the vertex set V to be printededgeSet
- the edge set E to be printeddirected
- true to use parens for each edge (representing directed);
false to use curly braces (representing undirected)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |