pyworkflow.utils.graph module

This module define a Graph class and some utilities

class pyworkflow.utils.graph.Graph(rootName='ROOT', root=None)[source]

Bases: object

Simple directed Graph class. Implemented using adjacency lists.

aliasNode(node, aliasName)[source]

Register an alias name for the node.

createNode(nodeName, nodeLabel=None) Node[source]

Add a node to the graph

getNode(nodeName) Node[source]
getNodeNames()[source]

Returns all the keys in the node dictionary

getNodes()[source]
getRoot() Node[source]
getRootNodes()[source]

Return all nodes that have no parent.

class pyworkflow.utils.graph.Node(name=None, label=None)[source]

Bases: object

A node inside the graph.

addChild(*nodes)[source]
countChildren(visitedNode=None, count=0)[source]

Iterate over all childs and subchilds. Nodes can be visited once

getChildren()[source]
getLabel()[source]
getName()[source]
getParent()[source]

Return the first parent in the list, if the node isRoot, None is returned.

getParents()[source]
isRoot()[source]
iterChildren()[source]

Iterate over all children and sub-children. Nodes can be visited more than once if it has more than one parent.

iterChildrenBreadth()[source]

Iter child nodes in a breadth-first order

setLabel(newLabel)[source]