T
- the type of elements in this graphpublic interface DirectedGraph<T> extends Set<T>
DirectedGraph
interface provides a collection of nodes with
outgoing edges to other nodes.Modifier and Type | Interface and Description |
---|---|
static interface |
DirectedGraph.Node<T>
The
Node interface represents a specific node in this directed
graph. |
Modifier and Type | Method and Description |
---|---|
void |
add(T start,
java.util.stream.Stream<T> dests)
Adds the specified nodes if they don't exist in the graph and build arcs
from the starting node to all the destination ones.
|
void |
add(T start,
T dest)
Adds the specified nodes if they don't exist in the graph and build an arc
from the starting node to the destination one.
|
void |
addEdge(T start,
T dest)
Adds an arc from the starting node to the destination one.
|
boolean |
edgeExists(T start,
T dest)
Given two nodes in the graph, returns whether there is an edge from the
first node to the second node.
|
java.util.stream.Stream<T> |
edgesFrom(T node)
Given a node in the graph, returns a stream of the edges leaving that node.
|
DirectedGraph.Node<T> |
get(T val)
Gets a node from this graph given its value.
|
Set<T> |
getEdgesFrom(T node)
Given a node in the graph, returns an immutable view of the edges
leaving that node as a set of endpoints.
|
Set<DirectedGraph.Node<T>> |
nodeSet()
Gets a
Set view of all the nodes contained in this directed graph. |
boolean |
removeEdge(T start,
T dest)
Removes the edge from the specified starting node to the specified destination
node from the graph.
|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, spliterator, toArray, toArray
parallelStream, removeIf, stream
DirectedGraph.Node<T> get(T val)
val
- the value for the node to retrievenull
if the
graph doesn't contain a node with the specified valueSet<DirectedGraph.Node<T>> nodeSet()
Set
view of all the nodes contained in this directed graph.
The set is backed by the graph, so changes to the graph are reflected in
the set, and vice-versa. If the graph is modified while an iteration over
the set is in progress (except through the iterator's own remove()
operation, or through the addEdge()
or removeEdge()
operations on a graph node returned by the iterator) the results of the
iteration are undefined. The set supports node removal, which removes the
corresponding node from the graph, via the Iterator.remove()
,
Set.remove
, removeAll
, retainAll
,
and clear
operations. It does not support the add
or addAll
operations.
void add(T start, T dest)
start
- the starting nodedest
- the destination nodevoid add(T start, java.util.stream.Stream<T> dests)
start
- the starting nodedests
- the destination nodesvoid addEdge(T start, T dest)
start
- the starting nodedest
- the destination nodeNoSuchElementException
- if either nodes do not existboolean removeEdge(T start, T dest)
start
- the starting nodedest
- the destination nodetrue
if an edge was removed; false
otherwiseNoSuchElementException
- if either nodes do not existboolean edgeExists(T start, T dest)
start
- the starting nodedest
- the destination nodetrue
if an edge exists from start
to
dest
; false
otherwiseNoSuchElementException
- if either nodes do not existjava.util.stream.Stream<T> edgesFrom(T node)
node
- the node whose edges should be queriedNoSuchElementException
- if the node does not existSet<T> getEdgesFrom(T node)
node
- the node whose edges should be queriedNoSuchElementException
- if the node does not existCopyright (C) 2015-2017 The Helenus Driver Project Authors.