V
- Type of the verticesE
- Type of the edgespublic interface Graph<V,E>
extends java.io.Serializable
Modifier and Type | Method and Description |
---|---|
void |
add(V source,
V dest,
E data)
Adds vertices (if not already in the graph) and the edge between them.
|
boolean |
addVertex(V v)
For adding a zero degree vertex
|
void |
clear()
clears the graph, removes all edges and nodes
|
boolean |
containsVertex(V v) |
java.util.List<E> |
getAllEdges() |
java.util.Set<V> |
getAllVertices() |
java.util.Set<V> |
getChildren(V vertex)
for undirected graph, it is just the neighbors
|
java.util.List<java.util.Set<V>> |
getConnectedComponents() |
java.util.List<E> |
getEdges(V source,
V dest) |
java.util.List<E> |
getIncomingEdges(V v)
for undirected graph, it is just the edges from the node
|
int |
getInDegree(V vertex)
for undirected graph, it should just be the degree
|
java.util.Set<V> |
getNeighbors(V v) |
int |
getNumEdges() |
int |
getNumVertices() |
int |
getOutDegree(V vertex) |
java.util.List<E> |
getOutgoingEdges(V v)
for undirected graph, it is just the edges from the node
|
java.util.Set<V> |
getParents(V vertex)
for undirected graph, it is just the neighbors
|
boolean |
isEdge(V source,
V dest)
only checks if there is an edge from source to dest.
|
boolean |
isEmpty()
False if there are any vertices in the graph, true otherwise.
|
boolean |
isNeighbor(V source,
V dest) |
boolean |
removeEdge(V source,
V dest,
E data) |
boolean |
removeEdges(V source,
V dest) |
boolean |
removeVertex(V vertex)
remove a vertex (and its edges) from the graph.
|
boolean |
removeVertices(java.util.Collection<V> vertices) |
void |
removeZeroDegreeNodes()
Deletes nodes with zero incoming and zero outgoing edges
|
void add(V source, V dest, E data)
source
- dest
- data
- boolean addVertex(V v)
v
- boolean removeVertex(V vertex)
vertex
- boolean removeVertices(java.util.Collection<V> vertices)
int getNumVertices()
java.util.List<E> getOutgoingEdges(V v)
v
- java.util.List<E> getIncomingEdges(V v)
v
- int getNumEdges()
java.util.Set<V> getParents(V vertex)
vertex
- java.util.Set<V> getChildren(V vertex)
vertex
- void clear()
boolean containsVertex(V v)
boolean isEdge(V source, V dest)
source
- dest
- java.util.Set<V> getAllVertices()
java.util.List<E> getAllEdges()
boolean isEmpty()
void removeZeroDegreeNodes()
int getInDegree(V vertex)
vertex
- int getOutDegree(V vertex)
java.util.List<java.util.Set<V>> getConnectedComponents()