|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--ptolemy.graph.Graph
|
+--ptolemy.graph.DirectedGraph
|
+--ptolemy.graph.DirectedAcyclicGraph
A directed acyclic graph (DAG).
The graphs constructed by this class cannot have cycles. For performance
reasons, this requirement is not checked (except for self-loops) during
the construction of the graph (calls to add and
addEdge), but is checked when any of the other methods is
called for the first time after the addition of nodes or edges. If the
graph is cyclic, an InvalidStateException is thrown. The check for cycles
is done by computing the transitive closure, so the first operation after
a graph change is slower.
This class implements the CPO interface since the Hasse diagram of a CPO
can be viewed as a DAG. Therefore, this class can be viewed as both a DAG
and a finite CPO. In the case of CPO, the node weights
are the CPO elements. The CPO does not require the bottom
element to exist. The call to bottom returns
null if the bottom element does not exist.
NOTE: This class is a starting point for implementing graph algorithms, more methods will be added.
| Fields inherited from class ptolemy.graph.DirectedGraph |
_transitiveClosure |
| Fields inherited from interface ptolemy.graph.CPO |
HIGHER, INCOMPARABLE, LOWER, SAME |
| Constructor Summary | |
DirectedAcyclicGraph()
Construct an empty DAG. |
|
DirectedAcyclicGraph(int nodeCount)
Construct an empty DAG with enough storage allocated for the specified number of elements. |
|
| Method Summary | |
protected Edge |
_addEdge(Node node1,
Node node2,
boolean weighted,
java.lang.Object weight)
Create and add an edge with a specified source node, sink node, and optional weight. |
protected Graph |
_emptyGraph()
Return an empty DAG. |
protected void |
_initializeListeners()
Create and register all of the change listeners for this graph, and initialize the change counter of the graph. |
java.lang.Object |
bottom()
Return the bottom element of this CPO. |
int |
compare(java.lang.Object e1,
java.lang.Object e2)
Compare two elements in this CPO. |
java.lang.Object[] |
downSet(java.lang.Object e)
Compute the down-set of an element in this CPO. |
java.lang.Object |
greatestElement(java.lang.Object[] subset)
Compute the greatest element of a subset. |
java.lang.Object |
greatestLowerBound(java.lang.Object[] subset)
Compute the greatest lower bound (GLB) of a subset. |
java.lang.Object |
greatestLowerBound(java.lang.Object e1,
java.lang.Object e2)
Compute the greatest lower bound (GLB) of two elements. |
boolean |
isLattice()
Test if this CPO is a lattice. |
java.lang.Object |
leastElement(java.lang.Object[] subset)
Compute the least element of a subset. |
java.lang.Object |
leastUpperBound(java.lang.Object[] subset)
Compute the least upper bound (LUB) of a subset. |
java.lang.Object |
leastUpperBound(java.lang.Object e1,
java.lang.Object e2)
Compute the least upper bound (LUB) of two elements. |
java.lang.Object |
top()
Return the top element of this CPO. |
java.lang.Object[] |
topologicalSort()
Topological sort the whole graph. |
java.lang.Object[] |
topologicalSort(java.lang.Object[] objects)
Sort the given graph objects in their topological order. |
java.lang.Object[] |
upSet(java.lang.Object e)
Compute the up-set of an element in this CPO. |
| Methods inherited from class ptolemy.graph.Graph |
_registerChange, add, addAll, addEdge, addEdge, addEdge, addEdge, addEdge, addListener, addNode, addNode, addNodeWeight, addNodeWeights, changeCount, connectedComponents, contains, containsEdge, containsEdgeWeight, containsNode, containsNodeWeight, description, edge, edge, edgeCount, edgeLabel, edgeLabel, edges, edges, edges, edgeWeight, incidentEdgeCount, incidentEdges, neighborEdges, neighbors, node, node, nodeCount, nodeLabel, nodeLabel, nodes, nodes, nodes, nodeWeight, removeEdge, removeNode, selfLoopEdgeCount, selfLoopEdges, selfLoopEdges, subgraph, subgraph, subgraph, toString, weightArray |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public DirectedAcyclicGraph()
public DirectedAcyclicGraph(int nodeCount)
nodeCount - The number of elements.| Method Detail |
public java.lang.Object bottom()
bottom in interface CPOnull if the bottom does not exist.
public int compare(java.lang.Object e1,
java.lang.Object e2)
compare in interface CPOe1 - An Object representing a CPO element.e2 - An Object representing a CPO element.CPO.LOWER, CPO.SAME,
CPO.HIGHER, CPO.INCOMPARABLE.java.lang.IllegalArgumentException - If at least one of the
specified Objects is not an element of this CPO.public java.lang.Object[] downSet(java.lang.Object e)
downSet in interface CPOe - An Object representing an element in this CPO.java.lang.IllegalArgumentException - If the specified Object is not
an element in this CPO.
public java.lang.Object greatestLowerBound(java.lang.Object e1,
java.lang.Object e2)
greatestLowerBound in interface CPOe1 - An Object representing an element in this CPO.e2 - An Object representing an element in this CPO.null if the GLB does not exist.java.lang.IllegalArgumentException - If at least one of the
specified Objects is not an element of this CPO.public java.lang.Object greatestLowerBound(java.lang.Object[] subset)
null is returned.greatestLowerBound in interface CPOsubset - An array of Objects representing the subset.null if the GLB does not exist.java.lang.IllegalArgumentException - If at least one Object
in the specified array is not an element of this CPO.public java.lang.Object greatestElement(java.lang.Object[] subset)
greatestElement in interface CPOsubset - An array of Objects representing the subset.null if the greatest element does not exist.java.lang.IllegalArgumentException - If at least one Object in the
specified array is not an element of this CPO.public boolean isLattice()
isLattice in interface CPOfalse otherwise.public java.lang.Object leastElement(java.lang.Object[] subset)
leastElement in interface CPOsubset - An array of Objects representing the subset.null if the least element does not exist.java.lang.IllegalArgumentException - If at least one Object in the
specified array is not an element of this CPO.
public java.lang.Object leastUpperBound(java.lang.Object e1,
java.lang.Object e2)
leastUpperBound in interface CPOe1 - An Object representing an element in this CPO.e2 - An Object representing element in this CPO.null if the LUB does not exist.java.lang.IllegalArgumentException - If at least one of the
specified Objects is not an element of this CPO.public java.lang.Object leastUpperBound(java.lang.Object[] subset)
null is returned.leastUpperBound in interface CPOsubset - An array of Objects representing the subset.null if the LUB does not exist.java.lang.IllegalArgumentException - If at least one Object
in the specified array is not an element of this CPO.public java.lang.Object top()
top in interface CPOnull if the top does not exist.public java.lang.Object[] topologicalSort()
InvalidStateException - If the graph is cyclic.public java.lang.Object[] topologicalSort(java.lang.Object[] objects)
public java.lang.Object[] upSet(java.lang.Object e)
upSet in interface CPOe - An Object representing an element in this CPO.java.lang.IllegalArgumentException - If the specified Object is not
an element of this CPO.
protected Edge _addEdge(Node node1,
Node node2,
boolean weighted,
java.lang.Object weight)
_addEdge in class Graphnode1 - The source node of the edge.node2 - The sink node of the edge.weighted - True if the edge is to be weighted.weight - The weight that is to be applied if the edge is to
be weighted.java.lang.IllegalArgumentException - If either of the specified nodes
is not in the graph, or if the specified nodes are identical.java.lang.NullPointerException - If the edge is to be weighted, but
the specified weight is null.protected Graph _emptyGraph()
_emptyGraph in class DirectedGraphprotected void _initializeListeners()
_initializeListeners in class DirectedGraph
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||