V
- the vertex value typepublic interface Graph<V> extends Iterable<Graph.Vertex<V>>
Object.equals(Object)
.Graphs
Modifier and Type | Interface and Description |
---|---|
static interface |
Graph.Vertex<V>
Represents a vertex and its successor.
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(V source,
V destination)
Adds a directed edge from the
source to destination . |
void |
addEdges(V source,
Collection<? extends V> destinations)
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.
|
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.
|
boolean |
isConnected(Object source,
Object destination)
Returns whether this graph contains the edge from
source to destination or not. |
boolean |
isEmpty()
Returns whether this graph is empty or not.
|
void |
removeEdge(Object source,
Object destination)
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.
|
forEach, iterator, spliterator
void addEdge(V source, V destination)
source
to destination
.
This method ignores the edge if it is already in this graph.
This method also addNode(Object)
source
and destination
vertices to this graph
if they are not in this graph.source
- the source vertex value (predecessor)destination
- the destination vertex value (successor)void addEdges(V source, Collection<? extends V> destinations)
source
to each vertex in destinations
.
This method ignores an edge if it is already in this graph.
This method also 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.source
- the tail vertex value (predecessor)destinations
- the head vertex values (successors)IllegalArgumentException
- if to
is null
void addNode(V node)
node
- the vertex valuevoid clear()
boolean contains(Object node)
node
- the target vertex valuetrue
if this graph contains the target vertex, otherwise false
Set<V> getConnected(Object key)
key
- the target vertex valueSet<V> getNodeSet()
boolean isConnected(Object source, Object destination)
source
to destination
or not.source
- the source vertex value (predecessor)destination
- the destination vertex value (successor)true
if this graph contains the edge from source
to destination
,
otherwise false
boolean isEmpty()
true
if this graph does not contains any vertices, otherwise false
void removeEdge(Object source, Object destination)
source
to destination
in this graph.
If this graph does not contain such the edge, this method will do nothing.source
- the source vertex value (predecessor)destination
- the destination vertex value (successor)void removeNode(Object node)
node
- the target vertex valuevoid removeNodes(Collection<?> nodes)
nodes
- the target verticesIllegalArgumentException
- if the parameter is null
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.