|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface for graphs, both directed and undirected. The implementation depends on whether the adjacency list or adjacency matrix representation is used.
Method Summary | |
void |
addEdge(int u,
int v)
Adds an edge to this graph. |
void |
addEdge(com.mhhe.clrs2e.Vertex u,
com.mhhe.clrs2e.Vertex v)
Adds an edge to this graph. |
com.mhhe.clrs2e.Vertex |
addVertex(int index,
java.lang.String name)
Adds a vertex to this graph. |
com.mhhe.clrs2e.Vertex |
addVertex(java.lang.String name)
Adds a vertex to this graph. |
com.mhhe.clrs2e.Vertex |
addVertex(com.mhhe.clrs2e.Vertex v)
Adds a vertex to this graph, given a Vertex. |
java.util.Iterator |
edgeIterator(int u)
Returns an iterator that iterates through the edges incident on a given vertex. |
java.util.Iterator |
edgeIterator(com.mhhe.clrs2e.Vertex u)
Returns an iterator that iterates through the edges incident on a given vertex. |
int |
getCardE()
Returns the number of edges in this graph. |
int |
getCardV()
Returns the number of vertices in this graph. |
com.mhhe.clrs2e.Vertex |
getVertex(int index)
Returns the vertex with a given index. |
boolean |
isDirected()
Returns true if this graph is directed,
false if undirected. |
java.util.Iterator |
vertexIterator()
Returns an iterator that iterates though all the vertices in the graph. |
Method Detail |
public com.mhhe.clrs2e.Vertex addVertex(java.lang.String name)
Vertex
object is created and added. The next
available index is used.
name
- The vertex's name.
Vertex
object added.public com.mhhe.clrs2e.Vertex addVertex(int index, java.lang.String name)
Vertex
object is created and added.
index
- The vertex's index.name
- The vertex's name.
Vertex
object added.public com.mhhe.clrs2e.Vertex addVertex(com.mhhe.clrs2e.Vertex v)
Vertex. If
the vertex's index is unknown, use the next available index.
Otherwise, use the index in the vertex.
- Parameters:
v
- The Vertex
object to add.
- Returns:
v
.
public com.mhhe.clrs2e.Vertex getVertex(int index)
index
- The index of the vertex.
Vertex
with the given index.public void addEdge(com.mhhe.clrs2e.Vertex u, com.mhhe.clrs2e.Vertex v)
Vertex
objects.
u
- One vertex.v
- The other vertex.public void addEdge(int u, int v)
u
- The index of one vertex.v
- The index of the other vertex.public java.util.Iterator vertexIterator()
public java.util.Iterator edgeIterator(com.mhhe.clrs2e.Vertex u)
u
- The vertex whose incident edges are returned by the
iterator.public java.util.Iterator edgeIterator(int u)
u
- The index of the vertex whose incident edges are
returned by the iterator.public int getCardV()
public int getCardE()
public boolean isDirected()
true
if this graph is directed,
false
if undirected.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |