|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GraphRepresentation<V,E extends Edge<V>>
The GraphRepresentation
interface
defines the methods that must be
supported by any graph representation,
such as the adjacency list and adjacency matrix representations. This design
allows different types of graphs
(e.g., weighted and unweighted)
to independently choose their internal representation from among the classes that
implement GraphRepresentation
.
Method Summary | |
---|---|
void |
addEdge(E edge)
Adds the given edge to this graph. |
boolean |
addVertex(V vertex)
Adds the given vertex to this graph unless it is already in the graph. |
boolean |
containsEdge(V source,
V dest)
Returns true if and only if there is an edge in the graph from the source vertex to the destination vertex. |
boolean |
containsVertex(V vertex)
Returns true if and only if the give vertex is in the graph. |
Iterator<E> |
edgesFrom(V source)
Returns an iterator over the outgoing edges from source . |
Iterator<E> |
edgesTo(V dest)
Returns an iterator over the incoming edges from dest . |
E |
getEdge(V source,
V dest)
Returns an edge in the graph from source to dest ,
or null if there is no such edge. |
boolean |
isDirected()
Returns true if and only if this graph representation is being used to support a directed graph. |
NonMutatingIterator<V> |
iterator()
Returns a non-mutating iterator over the vertices of the graph. |
int |
numVertices()
Returns the number of vertices in this graph. |
boolean |
removeEdge(E edge)
Returns true when the given edge is successfully removed, and false, if the edge did not exist. |
boolean |
removeVertex(V vertex)
Returns true if and only if the given vertex existed and was removed. |
Method Detail |
---|
void addEdge(E edge)
boolean addVertex(V vertex)
boolean containsEdge(V source, V dest)
boolean containsVertex(V vertex)
Iterator<E> edgesFrom(V source)
source
. Observe that
for an undirected graph, the iterator is over all edges incident to source
.
Iterator<E> edgesTo(V dest)
dest
.
This method throws an UnsupportedOperationException
when the graph representations
does not support this capability.
E getEdge(V source, V dest)
source
to dest
,
or null if there is no such edge.
boolean isDirected()
NonMutatingIterator<V> iterator()
removeVertex
method.
iterator
in interface Iterable<V>
int numVertices()
boolean removeEdge(E edge)
boolean removeVertex(V vertex)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |