public class Graph
extends java.lang.Object
Graph representation using the adjacency list form. See the book 'Introduction to Algorithms' by Cormen, Leiserson, and Rivest.
Constructor and Description |
---|
Graph() |
Modifier and Type | Method and Description |
---|---|
void |
addEdge(Edge edge)
Add an edge to the graph.
|
void |
addNode(java.lang.Object node)
Add a node to the graph.
|
void |
clear()
Clear the graph.
|
void |
clearTraversal()
Clear all nodes and edges of the bookkeeping information from their
last traversal.
|
boolean |
containsNode(java.lang.Object node)
Return true if the graph contains the given node.
|
java.util.Collection |
getEdges()
Return all edges in the graph.
|
java.util.Collection |
getEdges(java.lang.Object from,
java.lang.Object to)
Return all the edges from one node to another.
|
java.util.Collection |
getEdgesFrom(java.lang.Object node)
Return all the edges from a particular node.
|
java.util.Collection |
getEdgesTo(java.lang.Object node)
Return all the edges to a particular node.
|
java.util.Collection |
getNodes()
Return a view of all nodes in the graph.
|
boolean |
removeEdge(Edge edge)
Remove an edge from the graph.
|
boolean |
removeNode(java.lang.Object node)
Remove a node from the graph.
|
public void clear()
public boolean containsNode(java.lang.Object node)
public java.util.Collection getNodes()
public void addNode(java.lang.Object node)
public boolean removeNode(java.lang.Object node)
public java.util.Collection getEdges()
public java.util.Collection getEdgesFrom(java.lang.Object node)
public java.util.Collection getEdgesTo(java.lang.Object node)
public java.util.Collection getEdges(java.lang.Object from, java.lang.Object to)
public void addEdge(Edge edge)
public boolean removeEdge(Edge edge)
public void clearTraversal()