T - the type of node elements.
public class Graph<T> extends Object
| Constructor and Description |
|---|
Graph()
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEdge(T a, T b)
Add this edge to the graph.
|
void |
addNode(T node)
Add a node to the graph.
|
void |
addNodes(Set
Add all these nodes to the graph.
|
boolean |
containsEdge(T a, T b)
Returns
true if this graph contains the specified edge from
a to
b.
|
boolean |
containsNode(T node)
Returns
true if this graph contains the specified node.
|
int |
degreeIn(T node)
Get the number of incoming edges.
|
int |
degreeOut(T node)
Get the number of outgoing edges.
|
Set |
getEdgesIn(T node)
Get all incoming edges (the nodes that can be reached via these edges).
|
Set |
getEdgesOut(T node)
Get all outgoing edges (the nodes that can be reached via these edges).
|
Collection |
getNodes()
Return the nodes of this graph.
|
Set |
getPartition()
Get a partition of the graph.
|
Set |
getReachable(T node)
Find all nodes reachable in the graph starting from the specified node.
|
void |
removeAllNodes(Collection
Remove a collection of nodes from the graph.
|
void |
removeEdge(T a, T b)
Remove this edge from graph.
|
void |
removeNode(T node)
Remove a node from the graph.
|
Graph |
reversed()
Create a graph with the same nodes as this one, just all edges reversed.
|
public void addNode(T node)
node - the node to add.
public boolean containsNode(T node)
node - node whose presence in this graph is to be tested.
public void removeNode(T node)
node - the node to remove.
public void removeAllNodes(Collection<T> toRemove)
toRemove - the nodes to remove.
public void addNodes(Set<T> nodesToAdd)
nodesToAdd - a set of nodes to add.
public void addEdge(T a, T b)
a - a node.
b - another node.
public boolean containsEdge(T a, T b)
a - a node.
b - another node.
public void removeEdge(T a, T b)
a - a node.
b - another node.
public Collection<T> getNodes()
public Set<T> getEdgesOut(T node)
node - the node whose edges to get.
public Set<T> getEdgesIn(T node)
node - the node whose incoming edges to get.
public int degreeIn(T node)
node - the node.
public int degreeOut(T node)
node - the node.
public Set<Set <T>> getPartition()
public Set<T> getReachable(T node)
node - the node to start the traversal of the graph from.
public Graph<T> reversed()