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, wait
forEach, spliterator
public void addEdge(V from, V to)
Graph
source
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)
Graph
source
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)
Graph
public void clear()
Graph
public boolean contains(Object node)
Graph
public Set<V> getConnected(Object key)
Graph
getConnected
in interface Graph<V>
key
- the target vertex valuepublic Set<V> getNodeSet()
Graph
getNodeSet
in interface Graph<V>
public boolean isConnected(Object from, Object to)
Graph
source
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 false
public boolean isEmpty()
Graph
public Iterator<Graph.Vertex<V>> iterator()
iterator
in interface Iterable<Graph.Vertex<V>>
public void removeEdge(Object from, Object to)
Graph
source
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)
Graph
removeNode
in interface Graph<V>
node
- the target vertex valuepublic void removeNodes(Collection<?> nodes)
Graph
removeNodes
in interface Graph<V>
nodes
- the target verticesCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.