public class MapGraph extends java.lang.Object implements Graph
Modifier and Type | Class and Description |
---|---|
protected class |
MapGraph.BottomUpIterator
An inner iterator class that traverses through the Graph bottom up.
|
protected class |
MapGraph.MapGraphIterator
An inner iterator class that traverses through the Graph.
|
Modifier and Type | Field and Description |
---|---|
private LogManager |
mLogger
The handle to the logging manager.
|
protected java.util.Map |
mStore
The map indexed by the id of the
GraphNode , used for storing
the nodes of the Graph. |
Constructor and Description |
---|
MapGraph()
The default constructor.
|
MapGraph(boolean preserveInsertionOrder)
The overloaded constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addEdge(GraphNode parent,
GraphNode child)
Adds an edge between two already existing nodes in the graph.
|
void |
addEdge(java.lang.String parent,
java.lang.String child)
Adds an edge between two already existing nodes in the graph.
|
void |
addEdges(java.lang.String child,
java.util.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.
|
java.util.Iterator |
bottomUpIterator()
Returns an iterator that traverses the graph bottom up from the leaves.
|
java.lang.Object |
clone()
Returns a copy of the object.
|
java.lang.Object |
get(java.lang.Object key)
It returns the value associated with the key in the map.
|
java.util.List<GraphNode> |
getLeaves()
Returns the leaf nodes of the Graph.
|
GraphNode |
getNode(java.lang.String identifier)
Returns the node matching the id passed.
|
java.util.List<GraphNode> |
getRoots()
Returns the root nodes of the Graph.
|
boolean |
isEmpty()
Returns a boolean if there are no nodes in the graph.
|
java.util.Iterator |
iterator()
Returns an iterator that traverses through the graph using a graph
traversal algorithm.
|
java.util.Iterator |
nodeIterator()
Returns an iterator for the nodes in the Graph.
|
boolean |
remove(java.lang.String identifier)
Removes a node from the Graph.
|
void |
resetEdges()
Resets all the dependencies in the Graph, while preserving the nodes.
|
int |
size()
Returns the number of nodes in the graph.
|
java.util.Iterator<GraphNode> |
topologicalSortIterator()
Returns an iterator for the graph that traverses in topological sort
order.
|
java.lang.String |
toString()
The textual representation of the graph node.
|
protected java.util.Map mStore
GraphNode
, used for storing
the nodes of the Graph. The value for each key is the corresponding
GraphNode
of the class.private LogManager mLogger
public MapGraph()
public MapGraph(boolean preserveInsertionOrder)
preserveInsertionOrder
- a boolean indicating whether you want to
preserve insertion order. If set to true, the
nodeIterator() will return nodes in the order
they were added.public void addNode(GraphNode node)
public GraphNode getNode(java.lang.String identifier)
public void addRoot(GraphNode root)
public void resetEdges()
resetEdges
in interface Graph
public boolean remove(java.lang.String identifier)
public java.util.List<GraphNode> getRoots()
public java.util.List<GraphNode> getLeaves()
public void addEdge(java.lang.String parent, java.lang.String child)
public void addEdge(GraphNode parent, GraphNode child)
public void addEdges(java.lang.String child, java.util.List parents)
public int size()
public java.util.Iterator nodeIterator()
nodeIterator
in interface Graph
public java.util.Iterator iterator()
public java.util.Iterator bottomUpIterator()
bottomUpIterator
in interface Graph
public java.util.Iterator<GraphNode> topologicalSortIterator()
topologicalSortIterator
in interface Graph
public java.lang.String toString()
toString
in class java.lang.Object
public boolean isEmpty()
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.Object get(java.lang.Object key)
key
- the key to the entry in the map.