Package com.microstrategy.utils
Class DAG
- java.lang.Object
-
- com.microstrategy.utils.DAG
-
public class DAG extends java.lang.ObjectThis class represents a generic Directed Acyclic Graph. There are a number of inner classes that represent the parts of this DAG:DAG.Vertexrepresents a vertex in this graph.DAG.Edgerepresents 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 classDAG.AnnotatableObjectThis is a simple object which can be "annotated" with caller-specified properties.static classDAG.EdgeThis class represents an Edge in the Directed Acyclic Graph.static classDAG.VertexThis 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.EdgeaddEdge(DAG.Vertex fromVertex, DAG.Vertex toVertex)Adds an edge between two vertices.DAG.EdgegetEdge(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.MessageRoutergetMessageRouter()Returns the Message Router instance to use with this DAG.DAG.VertexgetVertex(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.voidsetMessageRouter(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.Vertexthat represents the "from" end.toVertex- TheDAG.Vertexthat 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.Vertexwhich is the "from" end.toVertex- TheDAG.Vertexwhich 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.Vertexassociated 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
IteratorofDAG.Vertexobjects.
-
getEdges
public java.util.Iterator<DAG.Edge> getEdges()
Returns all of the Edges in this DAG.- Returns:
- An
IteratorofDAG.Edgeobjects.
-
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
IteratorofDAG.Vertexobjects.
-
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
IteratorofDAG.Vertexobjects.
-
-