@@ -448,6 +448,49 @@ Or using the new syntax:
448
448
graph.get_cursor(a) >> b
449
449
450
450
451
+ Cursors
452
+ :::::::
453
+
454
+ Cursors are simple structures that references a graph, a starting point and a finishing point. They can be used to
455
+ manipulate graphs using the `>> ` operator in an intuitive way.
456
+
457
+ To grab a cursor from a graph, you have different options:
458
+
459
+ .. code-block :: python
460
+
461
+ # the most obvious way to get a cursor, its starting point will be "BEGIN"
462
+ cursor = graph.get_cursor()
463
+
464
+ # same thing, explicitely
465
+ cursor = graph.get_cursor(BEGIN )
466
+
467
+ # if you try to use a graph with the `>>` operator, it will create a cursor for you, from "BEGIN"
468
+ cursor = graph >> ... # same as `graph.get_cursor(BEGIN) >> ...`
469
+
470
+ # get a cursor pointing to nothing
471
+ cursor = graph.get_cursor(None )
472
+
473
+ # ... or in a more readable way
474
+ cursor = graph.orphan()
475
+
476
+ Once you get a cursor, you can use it to add nodes, concatenate it with othe cursors, etc. Everytime you call something
477
+ that should result in a changed cursor, you'll get a new instance so your old cursor will still be available if you need
478
+ it.
479
+
480
+ .. code-block :: python
481
+
482
+ c1 = graph.orphan()
483
+
484
+ # append a node, get a new cursor
485
+ c2 = c1 >> node1
486
+
487
+ # create an orphan chain
488
+ c3 = graph.orphan() >> normalize
489
+
490
+ # concatenate a chain to an existing cursor
491
+ c4 = c2 >> c3
492
+
493
+
451
494
Inspecting graphs
452
495
:::::::::::::::::
453
496
0 commit comments