public interface GraphIfc<V>
Modifier and Type | Method | Description |
---|---|---|
void |
addEdge(V u,
V v) |
Adds an edge between vertices u and v in the graph.
|
void |
addVertex(V v) |
Adds a vertex to the graph.
|
void |
clear() |
Removes all vertices from the graph
|
boolean |
containsNode(V v) |
Determines whether the given vertex is already contained in the graph.
|
int |
degree(V v) |
Returns the degree of the vertex.
|
boolean |
edgeExists(V v,
V u) |
Determines whether an edge exists between two vertices.
|
java.util.List<V> |
getNeighbors(V v) |
Returns the neighbors of v in the graph.
|
java.util.Set<V> |
getVertices() |
Returns the set of all vertices in the graph.
|
int |
numEdges() |
Returns the number of edges in the graph
|
int |
numVertices() |
Returns the number of vertices in the graph
|
java.lang.String |
toString() |
Returns a string representation of the graph.
|
int numVertices()
int numEdges()
void clear()
void addVertex(V v)
v
- The vertex to be addedvoid addEdge(V u, V v)
u
- A vertex in the graphv
- A vertex in the graphjava.lang.IllegalArgumentException
- if either vertex does not occur in the graph.java.util.Set<V> getVertices()
java.util.List<V> getNeighbors(V v)
v
- An existing node in the graphboolean containsNode(V v)
equals()
method in the class V.v
- The vertex to be tested.boolean edgeExists(V v, V u)
v
- A node in the graphu
- A node in the graphjava.lang.IllegalArgumentException
- if either vertex does not occur in the graphint degree(V v)
v
- A vertex in the graphjava.lang.IllegalArgumentException
- if the vertex does not occur in the graphjava.lang.String toString()
toString
in class java.lang.Object