|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--graph.HashKeyedDigraph
An implementation of KeyedDigraph that wraps another Digraph (no matter what its implementation) and adds a hash table.
| Field Summary | |
(package private) graph.Digraph |
g
The underlying graph. |
protected java.util.Map |
m
Maps keys to vertices. |
| Constructor Summary | |
HashKeyedDigraph(graph.Digraph g)
If g is an empty Digraph, this constructs a new empty KeyedDigraph. |
|
| Method Summary | |
static graph.KeyedDigraph |
fig12_15()
Returns the undirected, weighted graph from figure 12.15 of the textbook. |
static graph.KeyedDigraph |
fig12_2()
Returns the directed graph from figure 12.2 of the textbook. |
graph.Vertex |
findKeyedVertex(java.lang.Object k)
Return the vertex with key k. |
graph.Vertex |
findOrInsertKeyedVertex(java.lang.Object k)
Return the vertex with key k. |
graph.DirectedEdge |
insertDirectedEdge(graph.Vertex from,
graph.Vertex to,
java.lang.Object element)
Adds a new directed edge from one vertex to another. |
private void |
insertDistance(java.lang.String s1,
java.lang.String s2,
int i)
|
void |
insertReverseOf(graph.DirectedEdge e)
Convenience method: Add the reverse of the given edge, with the same element. |
graph.Vertex |
insertVertex(java.lang.Object element)
Insert and return a new vertex. |
graph.DirectedEdge |
keyedInsertDirectedEdge(java.lang.Object keyFrom,
java.lang.Object keyTo,
java.lang.Object element)
Convenience method: Add a directed edge between two keyed vertices, which are looked up or added using findOrInsertKeyedVertex(). |
static void |
main(java.lang.String[] args)
This test method does some work but doesn't actually print anything. |
int |
numEdges()
Return the size of the graph (number of edges, m). |
int |
numVertices()
Return the order of the graph (number of vertices, n). |
java.util.Iterator |
outIncidentEdges(graph.Vertex v)
Return an iterator over all the directed edges from a vertex. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
graph.Digraph g
protected java.util.Map m
| Constructor Detail |
public HashKeyedDigraph(graph.Digraph g)
Any vertices already in g will not be accessible via keys, but new vertices added through findOrInsertKeyedVertex may have keys.
| Method Detail |
public graph.Vertex findKeyedVertex(java.lang.Object k)
KeyedDigraph
findKeyedVertex in interface KeyedDigraphpublic graph.Vertex findOrInsertKeyedVertex(java.lang.Object k)
KeyedDigraphThis is the ONLY way to add a keyed vertex. Unkeyed vertices can be added with ordinary insertVertex(); but they do not have keys, and cannot be looked up by findKeyedVertex().
findOrInsertKeyedVertex in interface KeyedDigraph
public graph.DirectedEdge keyedInsertDirectedEdge(java.lang.Object keyFrom,
java.lang.Object keyTo,
java.lang.Object element)
KeyedDigraph
keyedInsertDirectedEdge in interface KeyedDigraphpublic int numVertices()
Digraph
numVertices in interface Digraphpublic int numEdges()
Digraph
numEdges in interface Digraphpublic java.util.Iterator outIncidentEdges(graph.Vertex v)
Digraph
outIncidentEdges in interface Digraphpublic graph.Vertex insertVertex(java.lang.Object element)
Digraph
insertVertex in interface Digraphelement - the element stored at the vertex.
public graph.DirectedEdge insertDirectedEdge(graph.Vertex from,
graph.Vertex to,
java.lang.Object element)
throws InvalidPositionException
Digraph
insertDirectedEdge in interface Digraphelement - the element stored on the edge.
InvalidPositionException - if the implementation detects that one
of the vertices is not actually in this graph.public void insertReverseOf(graph.DirectedEdge e)
Digraph
insertReverseOf(insertDirectedEdge(from, to, element));
This is convenient if from, to, or element is a complicated
expression.
insertReverseOf in interface Digraphpublic static graph.KeyedDigraph fig12_2()
private void insertDistance(java.lang.String s1,
java.lang.String s2,
int i)
public static graph.KeyedDigraph fig12_15()
public static void main(java.lang.String[] args)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||