graph
Interface KeyedDigraph

All Superinterfaces:
Digraph
All Known Implementing Classes:
HashKeyedDigraph

public interface KeyedDigraph
extends Digraph

A Digraph with keyed vertices. When you add a vertex, you can give it a unique key, by which you can look it up later.

A better version of this class would also support some other methods; you are asked to suggest some in your Readme file.


Method Summary
 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 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().
 
Methods inherited from interface graph.Digraph
insertDirectedEdge, insertReverseOf, insertVertex, numEdges, numVertices, outIncidentEdges
 

Method Detail

findKeyedVertex

public graph.Vertex findKeyedVertex(java.lang.Object k)
Return the vertex with key k.

Throws:
NoSuchVertexException - if there is no such vertex.

findOrInsertKeyedVertex

public graph.Vertex findOrInsertKeyedVertex(java.lang.Object k)
Return the vertex with key k. If there is none, create a new vertex with key k, and return it. The new vertex's element is initially k as well, but can be changed using Vertex.replaceElement().

This 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().


keyedInsertDirectedEdge

public 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().