public abstract class AbstractGraph<V,E> extends Object implements Graph<V,E>
Graph,
DirectedGraph,
UndirectedGraph| Modifier | Constructor and Description |
|---|---|
protected |
AbstractGraph()
Construct a new empty graph object.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
equals(Object obj)
Indicates whether some other object is "equal to" this graph.
|
int |
hashCode()
Returns a hash code value for this graph.
|
boolean |
removeAllEdges(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.
|
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(Collection<? extends V> vertices)
Removes all the vertices in this graph that are also contained in the
specified vertex collection.
|
String |
toString()
Returns a string of the parenthesized pair (V, E) representing this
G=(V,E) graph.
|
protected String |
toStringFromSets(Collection<? extends V> vertexSet,
Collection<? extends E> edgeSet,
boolean directed)
Helper for subclass implementations of toString( ).
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitaddEdge, addEdge, addVertex, containsEdge, containsVertex, edgeSet, edgesOf, getAllEdges, getEdge, getEdgeFactory, getEdgeSource, getEdgeTarget, getEdgeWeight, removeEdge, removeEdge, removeVertex, vertexSetpublic 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(Collection<? extends E> edges)
GraphGraph.removeEdge(Object) method.removeAllEdges in interface Graph<V,E>edges - edges to be removed from this graph.Graph.removeAllEdges(Collection)public Set<E> removeAllEdges(V sourceVertex, V targetVertex)
Graphnull 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 either vertex is not
part of graphGraph.removeAllEdges(Object, Object)public boolean removeAllVertices(Collection<? extends V> vertices)
GraphGraph.removeVertex(Object) method.removeAllVertices in interface Graph<V,E>vertices - vertices to be removed from this graph.Graph.removeAllVertices(Collection)public String toString()
protected boolean assertVertexExist(V v)
v - vertextrue if this assertion holds.NullPointerException - if specified vertex is null.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 String toStringFromSets(Collection<? extends V> vertexSet, 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)public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
true if the given object is also a graph, the two graphs are
instances of the same graph class, have identical vertices and edges sets
with the same weights.equals in class Objectobj - object to be compared for equality with this graphtrue if the specified object is equal to this graphObject.equals(Object)Copyright © 2016. All rights reserved.