|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.AbstractStructure<V> structure.GraphList<V,E>
public abstract class GraphList<V,E>
Implementation of graph using adjacency lists. Edges are stored in lists off of vertex structure. Class is abstract: you must use GraphListDirected or GraphListUndirected to construct particular instances of graphs. Typical usage:
Graph g = new GraphListDirected(); g.add("harry"); g.add("sally"); g.addEdge("harry","sally","friendly"); ...
GraphListDirected
,
GraphListUndirected
,
GraphMatrix
Method Summary | |
---|---|
void |
add(V label)
Add a vertex to the graph. |
abstract void |
addEdge(V v1,
V v2,
E label)
Add an edge between two vertices within the graph. |
void |
clear()
Remove all vertices (and thus, edges) of the graph. |
boolean |
contains(V label)
Test for vertex membership. |
boolean |
containsEdge(V vLabel1,
V vLabel2)
Test for edge membership. |
int |
degree(V label)
Determine out degree of vertex. |
abstract int |
edgeCount()
Determine the number of edges in graph. |
java.util.Iterator<Edge<V,E>> |
edges()
Construct an iterator over all edges. |
V |
get(V label)
Get reference to actual label of vertex. |
Edge<V,E> |
getEdge(V label1,
V label2)
Get reference to actual edge. |
boolean |
isDirected()
Determine if graph is directed. |
boolean |
isEmpty()
Determine if graph is empty. |
boolean |
isVisited(V label)
Return visited flag of vertex. |
boolean |
isVisitedEdge(Edge<V,E> e)
Return visited flag of edge. |
java.util.Iterator<V> |
iterator()
Construct vertex iterator. |
static void |
main(java.lang.String[] argv)
|
java.util.Iterator<V> |
neighbors(V label)
Construct an adjacent vertex iterator. |
abstract V |
remove(V label)
Remove a vertex from the graph. |
abstract E |
removeEdge(V vLabel1,
V vLabel2)
Remove possible edge between vertices labeled vLabel1 and vLabel2. |
void |
reset()
Clear visited flags of edges and vertices. |
int |
size()
Determine number of vertices within graph. |
boolean |
visit(V label)
Test and set visited flag of vertex. |
boolean |
visitEdge(Edge<V,E> e)
Test and set visited flag of edge. |
Methods inherited from class structure.AbstractStructure |
---|
elements, hashCode, values |
Methods inherited from class java.lang.Object |
---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface structure.Structure |
---|
elements, values |
Method Detail |
---|
public void add(V label)
add
in interface Graph<V,E>
add
in interface Structure<V>
label
- Label of the vertex; should be non-null.public abstract void addEdge(V v1, V v2, E label)
addEdge
in interface Graph<V,E>
vtx1
- First (or source, if directed) vertex.vtx2
- Second (or destination, if directed) vertex.label
- Label associated with the edge.public abstract V remove(V label)
remove
in interface Graph<V,E>
remove
in interface Structure<V>
label
- The label of the vertex within the graph.
public abstract E removeEdge(V vLabel1, V vLabel2)
removeEdge
in interface Graph<V,E>
vLabel1
- First (or source, if directed) vertex.vLabel2
- Second (or destination, if directed) vertex.
public V get(V label)
get
in interface Graph<V,E>
label
- The label of the vertex sought.
public Edge<V,E> getEdge(V label1, V label2)
getEdge
in interface Graph<V,E>
label1
- The first (or source, if directed) vertex.label2
- The second (or destination, if directed) vertex.
public boolean contains(V label)
contains
in interface Graph<V,E>
contains
in interface Structure<V>
contains
in class AbstractStructure<V>
label
- The label of the vertex sought.
public boolean containsEdge(V vLabel1, V vLabel2)
containsEdge
in interface Graph<V,E>
vLabel1
- First (or source, if directed) vertex.vLabel2
- Second (or destination, if directed) vertex.
public boolean visit(V label)
visit
in interface Graph<V,E>
label
- Label of vertex to be visited.
public boolean visitEdge(Edge<V,E> e)
visitEdge
in interface Graph<V,E>
e
- Edge object that is part of graph.
public boolean isVisited(V label)
isVisited
in interface Graph<V,E>
label
- Label of vertex.
public boolean isVisitedEdge(Edge<V,E> e)
isVisitedEdge
in interface Graph<V,E>
e
- Edge of graph to be considered.
public void reset()
reset
in interface Graph<V,E>
public int size()
size
in interface Graph<V,E>
size
in interface Structure<V>
public int degree(V label)
degree
in interface Graph<V,E>
label
- Label associated with vertex.
public abstract int edgeCount()
edgeCount
in interface Graph<V,E>
public java.util.Iterator<V> iterator()
iterator
in interface java.lang.Iterable<V>
iterator
in interface Graph<V,E>
iterator
in interface Structure<V>
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
public java.util.Iterator<V> neighbors(V label)
neighbors
in interface Graph<V,E>
label
- Label of the vertex.
public java.util.Iterator<Edge<V,E>> edges()
edges
in interface Graph<V,E>
public void clear()
clear
in interface Graph<V,E>
clear
in interface Structure<V>
public boolean isEmpty()
isEmpty
in interface Graph<V,E>
isEmpty
in interface Structure<V>
isEmpty
in class AbstractStructure<V>
public boolean isDirected()
isDirected
in interface Graph<V,E>
public static void main(java.lang.String[] argv)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |