V - the vertex value typepublic class HashGraph<V> extends Object implements Graph<V>
Graph.Vertex<V>| Constructor and Description |
|---|
HashGraph() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(V from,
V to)
Adds a directed edge from the
source to destination. |
void |
addEdges(V from,
Collection<? extends V> to)
Adds directed edges from the
source to each vertex in destinations. |
void |
addNode(V node)
Adds a vertex.
|
void |
clear()
Removes the all vertices and edges in this graph.
|
boolean |
contains(Object node)
Returns whether this graph contains the target vertex or not.
|
boolean |
equals(Object obj) |
Set<V> |
getConnected(Object key)
Returns the vertices which are direct successors of the specified vertex.
|
Set<V> |
getNodeSet()
Returns the all vertices in this graph.
|
int |
hashCode() |
boolean |
isConnected(Object from,
Object to)
Returns whether this graph contains the edge from
source to destination or not. |
boolean |
isEmpty()
Returns whether this graph is empty or not.
|
Iterator<Graph.Vertex<V>> |
iterator() |
void |
removeEdge(Object from,
Object to)
Removes the edge from
source to destination in this graph. |
void |
removeNode(Object node)
Removes the vertex in this graph.
|
void |
removeNodes(Collection<?> nodes)
Removes the vertices in this graph.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic void addEdge(V from, V to)
Graphsource to destination.
This method ignores the edge if it is already in this graph.
This method also Graph.addNode(Object) source and destination vertices to this graph
if they are not in this graph.public void addEdges(V from, Collection<? extends V> to)
Graphsource to each vertex in destinations.
This method ignores an edge if it is already in this graph.
This method also Graph.addNode(Object) source and each vertex in destinations to this graph
if they are not in this graph.
If destinations is an empty collection, this method will only add the source vertex
to this graph, and not add any edges.public void addNode(V node)
Graphpublic void clear()
Graphpublic boolean contains(Object node)
Graphpublic Set<V> getConnected(Object key)
GraphgetConnected in interface Graph<V>key - the target vertex valuepublic Set<V> getNodeSet()
GraphgetNodeSet in interface Graph<V>public boolean isConnected(Object from, Object to)
Graphsource to destination or not.isConnected in interface Graph<V>from - the source vertex value (predecessor)to - the destination vertex value (successor)true if this graph contains the edge from source to destination,
otherwise falsepublic boolean isEmpty()
Graphpublic Iterator<Graph.Vertex<V>> iterator()
iterator in interface Iterable<Graph.Vertex<V>>public void removeEdge(Object from, Object to)
Graphsource to destination in this graph.
If this graph does not contain such the edge, this method will do nothing.removeEdge in interface Graph<V>from - the source vertex value (predecessor)to - the destination vertex value (successor)public void removeNode(Object node)
GraphremoveNode in interface Graph<V>node - the target vertex valuepublic void removeNodes(Collection<?> nodes)
GraphremoveNodes in interface Graph<V>nodes - the target verticesCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.