This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.


PyDiGraph.add_edge(parent, child, edge, /)#

Add an edge between 2 nodes.

Use add_child() or add_parent() to create a node with an edge at the same time as an edge for better performance. Using this method allows for adding duplicate edges between nodes if the multigraph attribute is set to True.

  • parent (int) – Index of the parent node

  • child (int) – Index of the child node

  • edge – The object to set as the data for the edge. It can be any python object.


The edge index of the created edge

Return type:



When the new edge will create a cycle