Package com.microstrategy.utils
Class DAG
- java.lang.Object
-
- com.microstrategy.utils.DAG
-
public class DAG extends java.lang.Object
This class represents a generic Directed Acyclic Graph. There are a number of inner classes that represent the parts of this DAG:DAG.Vertex
represents a vertex in this graph.DAG.Edge
represents an edge in this graph that connects two vertices.
- Since:
- MicroStrategy Web 9.0.0
- See Also:
DAG.Vertex
,DAG.Edge
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DAG.AnnotatableObject
This is a simple object which can be "annotated" with caller-specified properties.static class
DAG.Edge
This class represents an Edge in the Directed Acyclic Graph.static class
DAG.Vertex
This class represents an end point ("vertex") in a Directed Acyclic Graph.
-
Constructor Summary
Constructors Constructor Description DAG()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DAG.Edge
addEdge(DAG.Vertex fromVertex, DAG.Vertex toVertex)
Adds an edge between two vertices.DAG.Edge
getEdge(DAG.Vertex fromVertex, DAG.Vertex toVertex)
Returns an Edge object which connects two Vertices.java.util.Iterator<DAG.Edge>
getEdges()
Returns all of the Edges in this DAG.MessageRouter
getMessageRouter()
Returns the Message Router instance to use with this DAG.DAG.Vertex
getVertex(java.lang.String vertexKey, boolean create)
Returns the Vertex associated with the supplied key.java.util.Iterator<DAG.Vertex>
getVertices()
Returns all of the Vertices in this DAG.void
setMessageRouter(MessageRouter msgRouter)
Sets the Message Router instance to use with this DAG.java.util.Iterator<DAG.Vertex>
sinkVertices()
Returns the list of sink vertices in the DAG.java.util.Iterator<DAG.Vertex>
topoSort()
Performs a topological sort on the contents of this DAG.
-
-
-
Method Detail
-
addEdge
public DAG.Edge addEdge(DAG.Vertex fromVertex, DAG.Vertex toVertex)
Adds an edge between two vertices. If an edge already exists between these vertices, it is returned.- Parameters:
fromVertex
- TheDAG.Vertex
that represents the "from" end.toVertex
- TheDAG.Vertex
that represents the "to" end.- Returns:
- An existing
DAG.Edge
(if one exists) or a newly created one that joins the two vertices.
-
getEdge
public DAG.Edge getEdge(DAG.Vertex fromVertex, DAG.Vertex toVertex)
Returns an Edge object which connects two Vertices. If not found, then null is returned.- Parameters:
fromVertex
- TheDAG.Vertex
which is the "from" end.toVertex
- TheDAG.Vertex
which is the "to" end.- Returns:
- Either the
DAG.Edge
, if it exists, or null.
-
getVertex
public DAG.Vertex getVertex(java.lang.String vertexKey, boolean create)
Returns the Vertex associated with the supplied key.- Parameters:
vertexKey
- The key for the Vertex to return.create
- If true and no Vertex was found, then a new Vertex object is created and returned. Otherwise, null is returned.- Returns:
- The
DAG.Vertex
associated with this key (or a new one if 'create' is true) or null.
-
getVertices
public java.util.Iterator<DAG.Vertex> getVertices()
Returns all of the Vertices in this DAG.- Returns:
- An
Iterator
ofDAG.Vertex
objects.
-
getEdges
public java.util.Iterator<DAG.Edge> getEdges()
Returns all of the Edges in this DAG.- Returns:
- An
Iterator
ofDAG.Edge
objects.
-
getMessageRouter
public MessageRouter getMessageRouter()
Returns the Message Router instance to use with this DAG.- Returns:
- The Message Router instance to use with this DAG.
-
setMessageRouter
public void setMessageRouter(MessageRouter msgRouter)
Sets the Message Router instance to use with this DAG.- Parameters:
msgRouter
- The Message Router instance to use with this DAG.
-
topoSort
public java.util.Iterator<DAG.Vertex> topoSort()
Performs a topological sort on the contents of this DAG. The results are a list of Vertices that satisfies this partial ordering.- Returns:
- A
Iterator
ofDAG.Vertex
objects.
-
sinkVertices
public java.util.Iterator<DAG.Vertex> sinkVertices()
Returns the list of sink vertices in the DAG. A sink vertex is a vertex without an out bound edge. A DAG should contain at least one sink vertex.- Returns:
- A
Iterator
ofDAG.Vertex
objects.
-
-