|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.datastructures.AdjacencyListGraph<V,E>
public class AdjacencyListGraph<V,E>
An realization of a graph according to adjacency list structure.
| Constructor Summary | |
|---|---|
AdjacencyListGraph()
Default constructor that creates an empty graph |
|
| Method Summary | ||
|---|---|---|
boolean |
areAdjacent(Vertex<V> u,
Vertex<V> v)
Test whether two vertices are adjacent |
|
int |
degree(Vertex<V> v)
Return the degree of a given vertex |
|
java.lang.Iterable<Edge<E>> |
edges()
Return an iterator over the edges of the graph |
|
Vertex<V>[] |
endVertices(Edge<E> e)
Return the endvertices of a edge in an array of length 2 |
|
java.lang.Iterable<Edge<E>> |
incidentEdges(Vertex<V> v)
Return an iterator over the edges incident on a vertex |
|
Edge<E> |
insertEdge(Vertex<V> v,
Vertex<V> w,
E o)
Insert and return a new edge with a given element between two vertices |
|
Vertex<V> |
insertVertex(V o)
Insert and return a new vertex with a given element |
|
int |
numEdges()
Returns the number of edges of the graph |
|
int |
numVertices()
Returns the number of vertices of the graph |
|
Vertex<V> |
opposite(Vertex<V> v,
Edge<E> e)
Return the other endvertex of an incident edge |
|
E |
removeEdge(Edge<E> e)
Remove an edge and return its element |
|
V |
removeVertex(Vertex<V> v)
Remove a vertex and all its incident edges and return the element stored at the removed vertex |
|
E |
replace(Edge<E> p,
E o)
Replaces the element of a given edge with a new element and returns the old element |
|
|
replace(Position<T> p,
T o)
Replace the element a given position (vertex or edge) with a new element and return the old element |
|
V |
replace(Vertex<V> p,
V o)
Replaces the element of a given vertex with a new element and returns the old element |
|
java.lang.String |
toString()
Returns a string representation of the vertex and edge lists, separated by a newline. |
|
java.lang.Iterable<Vertex<V>> |
vertices()
Return an iterator over the vertices of the graph |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AdjacencyListGraph()
| Method Detail |
|---|
public java.lang.Iterable<Vertex<V>> vertices()
vertices in interface Graph<V,E>public java.lang.Iterable<Edge<E>> edges()
edges in interface Graph<V,E>
public <T> T replace(Position<T> p,
T o)
throws InvalidPositionException
InvalidPositionException
public java.lang.Iterable<Edge<E>> incidentEdges(Vertex<V> v)
throws InvalidPositionException
incidentEdges in interface Graph<V,E>InvalidPositionException
public Vertex<V>[] endVertices(Edge<E> e)
throws InvalidPositionException
endVertices in interface Graph<V,E>InvalidPositionException
public Vertex<V> opposite(Vertex<V> v,
Edge<E> e)
throws InvalidPositionException
opposite in interface Graph<V,E>InvalidPositionException
public boolean areAdjacent(Vertex<V> u,
Vertex<V> v)
throws InvalidPositionException
areAdjacent in interface Graph<V,E>InvalidPositionExceptionpublic Vertex<V> insertVertex(V o)
insertVertex in interface Graph<V,E>
public Edge<E> insertEdge(Vertex<V> v,
Vertex<V> w,
E o)
throws InvalidPositionException
insertEdge in interface Graph<V,E>InvalidPositionException
public V removeVertex(Vertex<V> v)
throws InvalidPositionException
removeVertex in interface Graph<V,E>InvalidPositionException
public E removeEdge(Edge<E> e)
throws InvalidPositionException
removeEdge in interface Graph<V,E>InvalidPositionExceptionpublic int degree(Vertex<V> v)
public java.lang.String toString()
toString in class java.lang.Objectpublic int numVertices()
Graph
numVertices in interface Graph<V,E>public int numEdges()
Graph
numEdges in interface Graph<V,E>
public V replace(Vertex<V> p,
V o)
throws InvalidPositionException
Graph
replace in interface Graph<V,E>InvalidPositionException
public E replace(Edge<E> p,
E o)
throws InvalidPositionException
Graph
replace in interface Graph<V,E>InvalidPositionException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||