|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.AdjacencyListGraph
An realization of a graph according to adjacency list structure.
Nested Class Summary | |
protected static class |
AdjacencyListGraph.MyEdge
Implementation of an edge for an undirected adjacency list graph. |
protected static class |
AdjacencyListGraph.MyPosition
Implementation of a decorable position by means of a hash table. |
protected static class |
AdjacencyListGraph.MyVertex
Implementation of a vertex for an undirected adjacency list graph. |
Field Summary | |
protected NodeList |
E
|
protected NodeList |
V
|
Constructor Summary | |
AdjacencyListGraph()
Default constructor that creates an empty graph |
Method Summary | |
boolean |
areAdjacent(Vertex u,
Vertex v)
Test whether two vertices are adjacent |
protected AdjacencyListGraph.MyEdge |
checkEdge(Edge e)
Determines whether a given edge is valid. |
protected AdjacencyListGraph.MyPosition |
checkPosition(Position p)
Determines whether a given position is valid. |
protected AdjacencyListGraph.MyVertex |
checkVertex(Vertex v)
Determines whether a given vertex is valid. |
int |
degree(Vertex v)
Return the degree of a given vertex |
Iterator |
edges()
Return an iterator over the edges of the graph |
Vertex[] |
endVertices(Edge e)
Return the endvertices of a edge in an array of length 2 |
Iterator |
incidentEdges(Vertex v)
Return an iterator over the edges incident on a vertex |
Edge |
insertEdge(Vertex v,
Vertex w,
Object o)
Insert and return a new edge with a given element between two vertices |
Vertex |
insertVertex(Object o)
Insert and return a new vertex with a given element |
Vertex |
opposite(Vertex v,
Edge e)
Return the other endvertex of an incident edge |
Object |
removeEdge(Edge e)
Remove an edge and return its element |
Object |
removeVertex(Vertex v)
Remove a vertex and all its incident edges and return the element stored at the removed vertex |
Object |
replace(Position p,
Object o)
Replace the element a given position (vertex or edge) with a new element and return the old element |
String |
toString()
Returns a string representation of the vertex and edge lists, separated by a newline. |
Iterator |
vertices()
Return an iterator over the vertices of the graph |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected NodeList V
protected NodeList E
Constructor Detail |
public AdjacencyListGraph()
Method Detail |
public Iterator vertices()
vertices
in interface Graph
public Iterator edges()
edges
in interface Graph
public Object replace(Position p, Object o) throws InvalidPositionException
replace
in interface Graph
InvalidPositionException
public Iterator incidentEdges(Vertex v) throws InvalidPositionException
incidentEdges
in interface Graph
InvalidPositionException
public Vertex[] endVertices(Edge e) throws InvalidPositionException
endVertices
in interface Graph
InvalidPositionException
public Vertex opposite(Vertex v, Edge e) throws InvalidPositionException
opposite
in interface Graph
InvalidPositionException
public boolean areAdjacent(Vertex u, Vertex v) throws InvalidPositionException
areAdjacent
in interface Graph
InvalidPositionException
public Vertex insertVertex(Object o)
insertVertex
in interface Graph
public Edge insertEdge(Vertex v, Vertex w, Object o) throws InvalidPositionException
insertEdge
in interface Graph
InvalidPositionException
public Object removeVertex(Vertex v) throws InvalidPositionException
removeVertex
in interface Graph
InvalidPositionException
public Object removeEdge(Edge e) throws InvalidPositionException
removeEdge
in interface Graph
InvalidPositionException
public int degree(Vertex v)
protected AdjacencyListGraph.MyPosition checkPosition(Position p) throws InvalidPositionException
InvalidPositionException
protected AdjacencyListGraph.MyVertex checkVertex(Vertex v) throws InvalidPositionException
InvalidPositionException
protected AdjacencyListGraph.MyEdge checkEdge(Edge e) throws InvalidPositionException
InvalidPositionException
public String toString()
|
datastructures | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |