You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For the more flexible approach with better scaling use protocols to define the supported state types. Remember to always extend `typing.Protocol` in the child classes for typing.
37
37
38
-
This is recommended for scalable projects where many different state types need to be joined in one graph. See https://github.com/mathisxy/edgynodes/ for an example.
38
+
This is recommended for scalable projects where many different state types need to be joined in one graph. See [edgynodes](https://github.com/mathisxy/edgynodes/) for an example.
The edges are defined as a list of tuples, where the first element is the source and the second element reveals the next node.
48
48
49
+
### Branches
50
+
51
+
The edges are contained in branches. A branch is a tuple with edges and a join parameter at the end.
52
+
53
+
#### Spawning
54
+
55
+
A branch is spawned when the source of the first edge of the branch is triggered.
56
+
57
+
In this example it would be on `START`:
58
+
59
+
```python
60
+
edges=[(
61
+
(START, node1),
62
+
(node1, node2),
63
+
END
64
+
)]
65
+
```
66
+
67
+
In this example it would be on `node1` and on `node2` each:
68
+
69
+
```python
70
+
edges=[(
71
+
([node1, node2], node3),
72
+
node4
73
+
)]
74
+
```
75
+
76
+
#### Joining
77
+
78
+
The join parameter can be of the following types:
79
+
80
+
- `None`: The branch will not be joined.
81
+
- `END`: The branch will be joined at the end of the graph.
82
+
- A node instance: The branch will be joined directly before the given node is executed in any branch into this branch.
83
+
84
+
The process of joining describes waiting for the branches to finish wich aim to join and then applying the changes to the state of the whole finished branch to the state of the joining branch.
85
+
49
86
### Formats
50
87
51
-
The graph supports different formats for the edges.
88
+
A branch supports different formats for the edges.
52
89
53
90
- `(source, target)`: A single edge from source to target.
54
91
- `(START, target)`: A single edge from the start of the graph to target.
55
-
- `(source, END)`: A single edge from source to the end of the graph. It equals to `(source, None)`. It is redundant but can be used for better readability.
92
+
- `(source, None)`: A single edge from source to no target. `END` is not allowed here, since it would be redundant. It is only allowed in join parameters to distinct join at the end of the graph (`END`) from not joining (`None`)
56
93
- `([source1, source2], target)`: Multiple edges from source1 and source2 to target.
57
94
- `(source, [target1, target2])`: Multiple edges from source to target1 and target2.
58
95
- `([source1, source2], [target1, target2])`: Multiple edges from source1 and source2 to target1 and target2. This will create 4 edges in total.
0 commit comments