Performance: Conditional routing in graphs
MEDIUM IMPACT
This affects the speed of decision-making and response time in graph-based workflows by controlling which nodes execute based on conditions.
if condition: result = nodeA.run() else: result = nodeB.run() # Only one node runs based on condition
graph.add_edge('start', 'nodeA') graph.add_edge('start', 'nodeB') # Both nodes run regardless of condition resultA = nodeA.run() resultB = nodeB.run() # Condition checked after both run
| Pattern | Node Executions | Conditional Checks | Processing Time | Verdict |
|---|---|---|---|---|
| Run all nodes then check condition | All nodes run | After execution | High due to wasted runs | [X] Bad |
| Check condition before running nodes | Only needed node runs | Before execution | Lower, efficient processing | [OK] Good |