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
Providing a node to start the subgraph and optionally a set of node where you want the sub graph to end. If no node matching the ``to_nodes_id`` is encountered, the subgraph go until the leaf nodes of the graph.
226
+
The subgraph nodes are hard copy of the node of the initial graph. Modification to a subgraph doesn't impact its original.
227
+
This feature may be used as a fork mechanism (as seen above). It is easier to manipulate and monitor.
228
+
229
+
Usage Example:
230
+
231
+
```python
232
+
```python
233
+
# id0
234
+
# |
235
+
# .___ id1 ___.______.
236
+
# / | \ \
237
+
# id2 id3 id4 ida
238
+
# | / \ |
239
+
# | id5 id6 |
240
+
# \ \ / /
241
+
# `---- id7 ----'
242
+
# / \
243
+
# id8 id9
244
+
#
245
+
246
+
# If we decide to fork (with the fork id f1) from the node id4
FreExGraph provide a fork mechanism. It provides an easy way to duplicate a graph from a given node until the end of the graph (or to a specific node that would be used as a join).
Obviously if you want the node id4::f1 (which is of type FreExNode as you asked) to ever be visited by one of your visitor, you should provide your own node implementation.
254
300
255
-
It is also possible to provide a join node. It will be a node used as join for the fork in order to not have to fork the whole graph from the source of the fork. It is usefull if you have to multiply a big chunk of execution graph because one node has to change some internal values (in experimentation fields, it can be useful for parameter explorations).
301
+
It is also possible to provide a join node. It will be a node used as join for the fork in order to not have to fork the whole graph from the source of the fork.
302
+
It is useful if you have to multiply a big chunk of execution graph because one node has to change some internal values (in experimentation fields, it can be useful for parameter explorations).
256
303
257
-
> **Try avoiding forks** : This is a mecanism that can be useful in certain cases (the main one would be parameter exploration on an experimentation) But when it comes to map reduce for example, it is advised to manually fo the nodes you want instead (improve readibility of what you are doing when making your graph). A chaining of fork can start being very hard to understand for the user.
304
+
Under the hook, fork is using sub_graph and is reconstructing the links of the subgraph directly into the graph (and extends its name and parents name).
258
305
259
-
But if you want to do a map reduce with a fork, it is do-able by setting the join_id to the `fork_from_node` method. The join_id has to be an existing node on which, for every parents that are part of the fork has only this join node as child.
260
306
See [test using this mechanism](https://github.com/FreeYourSoul/FreExGraph/blob/ae707cf0fcb8486bde783cd0c7fe67217a56b3d2/test/fork_test.py#L41-L66) for more details
261
307
262
-
### Sub-Graph
263
-
264
-
A method exist in the `FreExGraph` class in order to make sub graph out of the graph.
Providing a node to start the subgraph and optionally a set of node where you want the sub graph to end. If no node matching the ``to_nodes_id`` is encountered, the subgraph go until the leaf nodes of the graph.
273
-
274
-
This feature may be used as a fork mechanism (as seen above). It is easier to manipulate and monitor.
0 commit comments