public interface MutableGraph<T>
extends java.io.Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
addNode(T node)
Adds
node if it is not already present. |
default boolean |
allowsSelfLoops()
Returns true if this graph allows self-loops (edges that connect a node to itself).
|
T |
getNodeById(java.lang.String id)
returns the node which has the given Id or null if no such node exsists
|
boolean |
isDirected()
Returns true if the edges in this graph are directed.
|
java.util.Set<T> |
nodes() |
java.util.Set<T> |
predecessors(T node)
Returns all nodes in this graph adjacent to
node which can be reached by traversing
node 's incoming edges against the direction (if any) of the edge. |
boolean |
putEdge(T orgin,
T target)
Adds an edge connecting
nodeU to nodeV if one is not already present. |
boolean |
removeEdge(T nodeU,
T nodeV)
Removes the edge connecting
nodeU to nodeV , if it is present. |
boolean |
removeNode(T node)
Removes
node if it is present; all edges incident to node will also be removed. |
java.util.Set<T> |
successors(T node)
Returns all nodes in this graph adjacent to
node which can be reached by traversing
node 's outgoing edges in the direction (if any) of the edge. |
boolean addNode(T node)
node
if it is not already present.
Nodes must be unique, just as Map
keys must be. They must also be non-null.
true
if the graph was modified as a result of this callboolean putEdge(T orgin, T target)
nodeU
to nodeV
if one is not already present.
If the graph is directed, the resultant edge will be directed; otherwise, it will be undirected.
If nodeU
and nodeV
are not already present in this graph, this method will
silently add
nodeU
and nodeV
to the graph.
true
if the graph was modified as a result of this calljava.lang.IllegalArgumentException
- if the introduction of the edge would violate allowsSelfLoops()
java.util.Set<T> nodes()
boolean removeNode(T node)
node
if it is present; all edges incident to node
will also be removed.true
if the graph was modified as a result of this callboolean removeEdge(T nodeU, T nodeV)
nodeU
to nodeV
, if it is present.true
if the graph was modified as a result of this calljava.util.Set<T> successors(T node)
node
which can be reached by traversing
node
's outgoing edges in the direction (if any) of the edge.java.lang.IllegalArgumentException
- if node
is not an element of this graphjava.util.Set<T> predecessors(T node)
node
which can be reached by traversing
node
's incoming edges against the direction (if any) of the edge.java.lang.IllegalArgumentException
- if node
is not an element of this graphdefault boolean allowsSelfLoops()
IllegalArgumentException
.boolean isDirected()
T getNodeById(java.lang.String id)
id
- the id of the node to return