c

org.codefeedr.pipeline

DirectedAcyclicGraph

final class DirectedAcyclicGraph extends AnyRef

A directed acyclic graph. Every Pipeline is enforced into a DAG, so that data cannot flow in a loop. Stage's are nodes in this graph whereas edges represent data flow using a org.codefeedr.buffer.Buffer.

This class is immutable so that graph can be build in a functional manner:

val dag = new DirectedAcyclicGraph()
  .addNode(nodeOne)
  .addNode(nodeTwo)
  .addEdge(nodeOne, nodeTwo)
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DirectedAcyclicGraph
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DirectedAcyclicGraph(nodes: Vector[AnyRef] = Vector(), edges: Vector[Edge] = Vector())

    nodes

    List of nodes to build the graph from.

    edges

    List of edges to build the graph from.

Value Members

  1. def addEdge(from: AnyRef, to: AnyRef): DirectedAcyclicGraph

    Adds an edge between two nodes in given graph.

    Adds an edge between two nodes in given graph.

    from

    The 'start' node.

    to

    The 'end' node.

    returns

    A new graph with the edge included

    Exceptions thrown

    IllegalArgumentException When either node is not in the graph or when the given edge causes a cycle.

  2. def addNode(node: AnyRef): DirectedAcyclicGraph

    Add given node to the graph.

    Add given node to the graph. Note: Nodes already in the graph will not be added again.

    node

    Node to add.

    returns

    A new graph with the node included.

  3. def canReach(from: AnyRef, to: AnyRef): Boolean

    Check whether there is a path from one node to the other.

    Check whether there is a path from one node to the other.

    from

    The 'from' node.

    to

    The 'to' node.

    returns

    true when there is a path.

  4. val edges: Vector[Edge]
  5. def equals(obj: Any): Boolean

    Equality check for a DAG.

    Equality check for a DAG.

    obj

    Object to compare with.

    returns

    True if equal.

    Definition Classes
    DirectedAcyclicGraph → AnyRef → Any
  6. def getChildren(node: AnyRef): Vector[AnyRef]

    Get children of a node.

    Get children of a node.

    node

    Node to get children from.

    returns

    A set with the children of the node. Note: can be the empty set.

  7. def getFirstParent(node: AnyRef): Option[AnyRef]

    Get the parent that is designated as first/primary parent.

    Get the parent that is designated as first/primary parent. This is the node which edges is found first.

    node

    Node to get first/primary parent from.

    returns

    The parent node. Note: Optional since the parent can be non-existing.

  8. def getParents(node: AnyRef): Vector[AnyRef]

    Get a parents of a node.

    Get a parents of a node.

    node

    Node to get parents from.

    returns

    A set with the parents of the node. Note: can be the empty set.

  9. def hasAnyEdge(node: AnyRef): Boolean

    Check whether the node has any edge at all.

    Check whether the node has any edge at all.

    node

    The node to check.

    returns

    True when it has more than zero edges.

  10. def hasEdge(from: AnyRef, to: AnyRef): Boolean

    Check whether an edge exists between two nodes.

    Check whether an edge exists between two nodes.

    from

    The 'from' node.

    to

    The 'to' node.

    returns

    True when an edge from 'from' to 'to'.

  11. def hasNode(node: AnyRef): Boolean

    Check whether given node is in the graph.

    Check whether given node is in the graph.

    node

    Node to verify.

    returns

    True if in node is in graph.

  12. def isEmpty: Boolean

    Check whether a graph is empty.

    Check whether a graph is empty.

    returns

    True when there are no nodes.

  13. def isSequential: Boolean

    Check whether the graph is sequential.

    Check whether the graph is sequential.

    Sequential means that there is no node with multiple parents or children. The whole set of nodes is a connected line. An empty graph is also sequential.

    returns

    True when the graph is sequential.

  14. def lastInSequence: Option[AnyRef]

    Find the last node, assuming this graph is sequential.

    Find the last node, assuming this graph is sequential.

    returns

    The last node or None if the graph is not sequential or empty.

  15. val nodes: Vector[AnyRef]
  16. def verify(): Unit

    Verifies the graph.

    Verifies the graph.

    1) InputStages cannot have incoming edges. 2) OutputStages cannot have outgoing edges. 3) The input types of stage must be equal to the output types of its incoming edges.

    Exceptions thrown

    InvalidPipelineException if the pipeline is invalid (invalid edges).

    StageTypesIncompatibleException if types within the pipeline are invalid.

  17. def withoutOrphans: DirectedAcyclicGraph

    Get a copy of the graph with all orphans removed.

    Get a copy of the graph with all orphans removed. Orphans are nodes without edges.

    returns

    The graph without orphan nodes.