Return a list of nodes that form a cycle if Dask is not a DAG. Returns an empty list if no cycle is found. ``keys`` may be a single key or list of keys. Examples -------- >>> inc = lambda x: x + 1 >>> d = {'x': (inc, 'z'), 'y': (inc, 'x'), 'z': (inc, 'y')} >>> getcycl
(d, keys)
| 458 | |
| 459 | |
| 460 | def getcycle(d, keys): |
| 461 | """Return a list of nodes that form a cycle if Dask is not a DAG. |
| 462 | |
| 463 | Returns an empty list if no cycle is found. |
| 464 | |
| 465 | ``keys`` may be a single key or list of keys. |
| 466 | |
| 467 | Examples |
| 468 | -------- |
| 469 | |
| 470 | >>> inc = lambda x: x + 1 |
| 471 | >>> d = {'x': (inc, 'z'), 'y': (inc, 'x'), 'z': (inc, 'y')} |
| 472 | >>> getcycle(d, 'x') |
| 473 | ['x', 'z', 'y', 'x'] |
| 474 | |
| 475 | See Also |
| 476 | -------- |
| 477 | isdag |
| 478 | """ |
| 479 | return _toposort(d, keys=keys, returncycle=True) |
| 480 | |
| 481 | |
| 482 | def isdag(d, keys): |
searching dependent graphs…