|
net.datastructures - version 5.0 | |||||||
| 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.
| Nested Class Summary | |
|---|---|
protected class |
AdjacencyListGraph.MyEdge<E>
Implementation of an edge for an undirected adjacency list graph. |
protected static class |
AdjacencyListGraph.MyPosition<T>
Implementation of a decorable position by means of a hash table. |
protected class |
AdjacencyListGraph.MyVertex<V>
Implementation of a vertex for an undirected adjacency list graph. |
| Field Summary | |
|---|---|
protected NodePositionList<Edge<E>> |
EList
|
protected NodePositionList<Vertex<V>> |
VList
|
| 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 |
protected AdjacencyListGraph.MyEdge<E> |
checkEdge(Edge<E> e)
Determines whether a given edge is valid. |
protected AdjacencyListGraph.MyPosition |
checkPosition(Position p)
Determines whether a given position is valid. |
protected AdjacencyListGraph.MyVertex<V> |
checkVertex(Vertex<V> v)
Determines whether a given vertex is valid. |
int |
degree(Vertex<V> v)
Return the degree of a given vertex |
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 |
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 |
Object |
replace(Position p,
Object 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 |
String |
toString()
Returns a string representation of the vertex and edge lists, separated by a newline. |
Iterable<Vertex<V>> |
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 NodePositionList<Vertex<V>> VList
protected NodePositionList<Edge<E>> EList
| Constructor Detail |
|---|
public AdjacencyListGraph()
| Method Detail |
|---|
public Iterable<Vertex<V>> vertices()
vertices in interface Graph<V,E>public Iterable<Edge<E>> edges()
edges in interface Graph<V,E>
public Object replace(Position p,
Object o)
throws InvalidPositionException
InvalidPositionException
public 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)
protected AdjacencyListGraph.MyPosition checkPosition(Position p)
throws InvalidPositionException
InvalidPositionException
protected AdjacencyListGraph.MyVertex<V> checkVertex(Vertex<V> v)
throws InvalidPositionException
InvalidPositionException
protected AdjacencyListGraph.MyEdge<E> checkEdge(Edge<E> e)
throws InvalidPositionException
InvalidPositionExceptionpublic String toString()
toString in class 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
|
net.datastructures - version 5.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||