|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Graph
The interface for the Graph Class. It implements the GraphNodeContent interface. This allows us to associate Graphs with the nodes in a Graph i.e. graph of graphs.
| Field Summary | |
|---|---|
static String |
VERSION
The version number associated with this Graph API. |
| Method Summary | |
|---|---|
void |
addEdge(String parent,
String child)
Adds an edge between two already existing nodes in the graph. |
void |
addEdges(String child,
List parents)
A convenience method that allows for bulk addition of edges between already existing nodes in the graph. |
void |
addNode(GraphNode node)
Adds a node to the Graph. |
void |
addRoot(GraphNode root)
Adds a single root node to the Graph. |
List<GraphNode> |
getLeaves()
Returns the leaf nodes of the Graph. |
GraphNode |
getNode(String identifier)
Returns the node matching the id passed. |
List<GraphNode> |
getRoots()
Returns the root nodes of the Graph. |
boolean |
isEmpty()
Returns a boolean if there are no nodes in the graph. |
Iterator<GraphNode> |
iterator()
Returns an iterator that traverses through the graph using a graph traversal algorithm. |
Iterator<GraphNode> |
nodeIterator()
Returns an iterator for the nodes in the Graph. |
boolean |
remove(String identifier)
Removes a node from the Graph. |
int |
size()
Returns the number of nodes in the graph. |
Iterator<GraphNode> |
topologicalSortIterator()
Returns an iterator for the graph that traverses in topological sort order. |
| Field Detail |
|---|
static final String VERSION
| Method Detail |
|---|
void addNode(GraphNode node)
node - the node to be added to the Graph.
void addEdge(String parent,
String child)
parent - the parent node ID.child - the child node ID.
void addEdges(String child,
List parents)
child - the child node IDparents - list of parent identifiers as String.GraphNode getNode(String identifier)
identifier - the id of the node.
void addRoot(GraphNode root)
root - the GraphNode to be added as a root.
RuntimeException - if a node with the same id already exists.boolean remove(String identifier)
identifier - the id of the node to be removed.
Iterator<GraphNode> nodeIterator()
Iterator<GraphNode> iterator()
Iterator<GraphNode> topologicalSortIterator()
int size()
List<GraphNode> getRoots()
GraphNode corressponding to the
root nodes.List<GraphNode> getLeaves()
GraphNode corressponding to the
leaf nodes.boolean isEmpty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||