paya.lib.evalgraph#
- class EvalGraph(dct)#
Simple directed-acyclic-graph simulator. Good for rig build sequences etc.
- Construction by Dictionary
EvalGraph
objects use a dictionary with the following structure:{ <nodeName>: [inputNodeName, inputNodeName...], <nodeName>: [inputNodeName, inputNodeName...], [...] }
A
EvalGraph
can be instantiated directly around such a dictionary, or viafromSegments()
, which may be more intuitive.Graphs
cannot be edited after instantiation, only analysed and evaluated.To get a build sequence for the entire graph, either iterate over the object or call
getBuildSequence()
.- classmethod fromSegments(segments)#
- Example
items = [ ['A', 'C', 'D', 'G'], ['B', 'C', 'E', 'H'], ['E', 'F', 'G'] ] graph = EvalGraph.fromSegments(items) print(list(graph)) # evaluate ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
- nodes(startTerminals=False, endTerminals=False, orphan=False)#
If
startTerminals
,endTerminals
andorphan
are omitted, all nodes will be returned.
- getNodeInputs(node)#
- getNodeOutputs(node)#
- getNodesUpstreamOf(node)#
- Parameters
node – the node to trace from
- Returns
All nodes upstream of node.
- Return type
[
str
]
- getNodesDownstreamOf(node)#
- Parameters
node – the node to trace from
- Returns
All nodes downstream of node.
- Return type
[
str
]
- getPath(start, end)#
- reduceTargetList(*targets)#
Given a list of target nodes, returns another list with duplicates and implied nodes (i.e. nodes that are already upstream of other nodes) removed.
- getBuildSequence(targets=None)#