Graph
dagpipe.graph
Summary
Defines DAG structure connecting nodes.
A Graph describes execution topology only. It does not execute nodes or manage
State. Execution is handled by an Engine.
Responsibilities
- Multiple roots, branching, and merging support.
- Deterministic traversal based on topology.
- Graph is mutable during construction but treated as immutable at runtime.
Classes
Graph
Directed Acyclic Graph defining execution topology of Node objects.
Notes
Responsibilities:
1 2 | |
Guarantees:
1 2 | |
Create an empty Graph.
Initializes node registry and edge mappings.
Functions
add_edge
Add a directed edge from src to dst.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
src |
Node
|
Source node. |
required |
dst |
Node
|
Destination node. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If the edge would create a cycle or if |
Notes
- Validates node types.
- Prevents cycles.
- Registers nodes if not present.
- Updates parent and child mappings.
add_root
Add a root node with no parents.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node |
Node
|
Node to add as a root. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If node is not a Node instance. |
children
nodes
Return all nodes in the graph.
Returns:
| Type | Description |
|---|---|
Tuple[Node, ...]
|
Tuple[Node, ...]: All registered nodes. |