V - the type of the datapublic class KeyGraph<V> extends Object implements Graph<V>
There exists a injection from the data to the vertices. This graph maintains a mapping from data to its vertex. New vertices are created on-the-fly.
For example, a 2-cycle graph:
KeyGraph<Character>graph = new KeyGraph<Character>();
graph.getVertex('a').addNeighbour(graph.getVertex('b'));
graph.getVertex('b').addNeighbour(graph.getVertex('a'));
| Constructor and Description |
|---|
KeyGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(V from,
V to) |
void |
addUndirectedEdge(V from,
V to) |
Vertex<V> |
getVertex(V data)
Returns the vertex associated with the data.
|
Collection<Vertex<V>> |
getVertices()
Return the set of vertices contained in the graph.
|
String |
toString() |
public KeyGraph()
public Vertex<V> getVertex(V data)
data - the dataObject.equals(Object),
Object.hashCode()public void addUndirectedEdge(V from, V to)
public Collection<Vertex<V>> getVertices()
getVertices in interface Graph<V>Copyright © 2013. All Rights Reserved.