org.knime.core.node.workflow
Class Workflow

java.lang.Object
  extended by org.knime.core.node.workflow.Workflow

 class Workflow
extends Object

Container class wrapping wrapping the network of nodes forming a workflow together with some of the basic functionality, especially traversal methods.

Author:
M. Berthold, University of Konstanz

Nested Class Summary
(package private)  class Workflow.NodeAndInports
          Helper class for lists of nodes with their inports
 
Field Summary
(package private)  TreeMap<NodeID,NodeContainer> m_nodes
          mapping from NodeID to Nodes.
 
Constructor Summary
Workflow(NodeID id)
          Constructor - initialize sets for meta node in/out connections.
 
Method Summary
(package private)  Set<Integer> connectedInPorts(int outPortIx)
          Determine inports which are connected (directly or indirectly) to the given outport in this workflow.
(package private)  Set<Integer> connectedOutPorts(int inPortIx)
          Determine outports which are connected (directly or indirectly) to the given inport in this workflow.
(package private)  boolean containsNodeKey(NodeID id)
           
(package private)  LinkedHashMap<NodeID,Set<Integer>> createBackwardsBreadthFirstSortedList(Set<Integer> outportIndices)
          Return map of node ids to set of port indices based on list of output ports.
(package private)  LinkedHashMap<NodeID,Set<Integer>> createBreadthFirstSortedList(Set<NodeID> ids, boolean skipWFM)
          Return map of node ids to set of port indices based on argument list of node ids.
(package private)  ArrayList<Workflow.NodeAndInports> findAllConnectedNodes(Set<Integer> inPorts)
          Determine all nodes which are connected (directly or indirectly) to the given inports in this workflow.
(package private)  ArrayList<Workflow.NodeAndInports> findAllNodesConnectedToLoopBody(NodeID startNode, NodeID endNode)
          Create list of nodes (id)s that are part of a loop body.
(package private)  LinkedHashMap<NodeID,Set<Integer>> getBreadthFirstListOfNodeAndSuccessors(NodeID id, boolean skipWFM)
          Return map of node ids connected to the given node sorted in breadth first order mapped to a set of portIDs.
(package private)  Set<ConnectionContainer> getConnectionsByDest(NodeID id)
          Return all connections having the same destination.
(package private)  Set<ConnectionContainer> getConnectionsBySource(NodeID id)
          Return all connections having the same destination.
(package private)  Collection<Set<ConnectionContainer>> getConnectionsBySourceValues()
           
(package private)  NodeID getID()
           
(package private)  NodeID getMatchingLoopEnd(NodeID id)
          Return matching LoopEnd node for the given LoopStart
(package private)  NodeID getMatchingLoopStart(NodeID id)
          Return matching LoopStart node for the given LoopEnd
(package private)  NodeContainer getNode(NodeID id)
          Return NodeContainer for a given id or null if that node does not exist in this workflow.
(package private)  Set<NodeID> getNodeIDs()
           
(package private)  Collection<NodeContainer> getNodeValues()
           
(package private)  int getNrNodes()
           
(package private)  void putNode(NodeID id, NodeContainer nc)
          Store NodeContainer with a given id.
(package private)  NodeContainer removeNode(NodeID id)
          Remove given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_nodes

final TreeMap<NodeID,NodeContainer> m_nodes
mapping from NodeID to Nodes.

Constructor Detail

Workflow

Workflow(NodeID id)
Constructor - initialize sets for meta node in/out connections.

Parameters:
id - of workflow
Method Detail

getID

NodeID getID()
Returns:
id of this workflow

getNode

NodeContainer getNode(NodeID id)
Return NodeContainer for a given id or null if that node does not exist in this workflow.

Parameters:
id - of the node
Returns:
node with that id

putNode

void putNode(NodeID id,
             NodeContainer nc)
Store NodeContainer with a given id.

Parameters:
id - of NC
nc - NodeContainer itself

removeNode

NodeContainer removeNode(NodeID id)
Remove given node.

Parameters:
id - of NodeContainer to be removed.
Returns:
removed NodeContainer

getNodeValues

Collection<NodeContainer> getNodeValues()
Returns:
collection of all NodeContainers that are part of this workflow.

getNodeIDs

Set<NodeID> getNodeIDs()
Returns:
collection of all NodeIDs that are part of this workflow.

getNrNodes

int getNrNodes()
Returns:
number of nodes

containsNodeKey

boolean containsNodeKey(NodeID id)
Parameters:
id - of node.
Returns:
true of a node with this key already exists.

getConnectionsByDest

Set<ConnectionContainer> getConnectionsByDest(NodeID id)
Return all connections having the same destination.

Parameters:
id - of destination node
Returns:
set as described above

getConnectionsBySource

Set<ConnectionContainer> getConnectionsBySource(NodeID id)
Return all connections having the same destination.

Parameters:
id - of destination node
Returns:
set as described above

getConnectionsBySourceValues

Collection<Set<ConnectionContainer>> getConnectionsBySourceValues()
Returns:
a collection of sets of ConnectionContainers, grouped by source node ID.

getBreadthFirstListOfNodeAndSuccessors

LinkedHashMap<NodeID,Set<Integer>> getBreadthFirstListOfNodeAndSuccessors(NodeID id,
                                                                          boolean skipWFM)
Return map of node ids connected to the given node sorted in breadth first order mapped to a set of portIDs. Note that also nodes which have another predecessors not contained in this list may be included as long as at least one input node is connected to a node in this list! The set of integers represents the indices of input ports which are actually used within the graph covered in the result list.

Parameters:
id - of node
skipWFM - if true, do not include WFM in the list
Returns:
map as described above.

createBreadthFirstSortedList

LinkedHashMap<NodeID,Set<Integer>> createBreadthFirstSortedList(Set<NodeID> ids,
                                                                boolean skipWFM)
Return map of node ids to set of port indices based on argument list of node ids. The map is sorted by traversing the graph breadth first, the set of port indices represents the input ports actually used within the graph covered.

Parameters:
ids - of interest, for example m_workflow.m_nodes.keySet()
skipWFM - if true, do not include WFM in the list
Returns:
BF sorted list of node ids

connectedOutPorts

Set<Integer> connectedOutPorts(int inPortIx)
Determine outports which are connected (directly or indirectly) to the given inport in this workflow.

Parameters:
inPortIx - index of inport
Returns:
set of outport indices

findAllConnectedNodes

ArrayList<Workflow.NodeAndInports> findAllConnectedNodes(Set<Integer> inPorts)
Determine all nodes which are connected (directly or indirectly) to the given inports in this workflow. The list is sorted according to "longest path layering" making sure that nodes are always added behind all of their predecessors.

Parameters:
inPorts - indices of inports
Returns:
set of nodes with used inports

connectedInPorts

Set<Integer> connectedInPorts(int outPortIx)
Determine inports which are connected (directly or indirectly) to the given outport in this workflow.

Parameters:
outPortIx - index of outport
Returns:
set of inport indices

createBackwardsBreadthFirstSortedList

LinkedHashMap<NodeID,Set<Integer>> createBackwardsBreadthFirstSortedList(Set<Integer> outportIndices)
Return map of node ids to set of port indices based on list of output ports. The map's iterator returns the elements sorted by traversing the graph backwards, breadth first, the set of port indices represents the input ports actually used within the graph covered. Include this WFM if any incoming ports are connected.

Parameters:
outportIndices - set of integers indicating the ports of interest
Returns:
BF sorted list of node ids

getMatchingLoopEnd

NodeID getMatchingLoopEnd(NodeID id)
                    throws IllegalLoopException,
                           IllegalArgumentException
Return matching LoopEnd node for the given LoopStart

Parameters:
id - The requested start node (instanceof LoopStart)
Returns:
id of end node or null if no such node was found.
Throws:
IllegalLoopException - if loop setup is wrong
IllegalArgumentException - if argument is not a LoopStart node

getMatchingLoopStart

NodeID getMatchingLoopStart(NodeID id)
                      throws IllegalLoopException,
                             IllegalArgumentException
Return matching LoopStart node for the given LoopEnd

Parameters:
id - The requested end node (instanceof LoopEnd)
Returns:
id of start node or null if no such node was found.
Throws:
IllegalLoopException - if loop setup is wrong
IllegalArgumentException - if argument is not a LoopEnd node

findAllNodesConnectedToLoopBody

ArrayList<Workflow.NodeAndInports> findAllNodesConnectedToLoopBody(NodeID startNode,
                                                                   NodeID endNode)
                                                             throws IllegalLoopException
Create list of nodes (id)s that are part of a loop body. Note that this also includes any dangling branches which leave the loop but do not connect back to the end-node. Used to re-execute all nodes of a loop. NOTE that this list can contain nodes more than one with different inport indices! The list is sorted according to "longest path layering" making sure that nodes are always added behind all of their predecessors. The list does not contain the start node or end node.

Parameters:
startNode - id of head of loop
endNode - if of tail of loop
Returns:
list of nodes within loop body & any dangling branches. The list also contains the used input ports of each node.
Throws:
IllegalLoopException - If there is a ill-posed loop (dangling branches)


Copyright, 2003 - 2012. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.