Note

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.

rustworkx.PyDAG.add_edge#

PyDAG.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.

Parameters:
  • 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.

Returns:

The edge index of the created edge

Return type:

int

Raises:

When the new edge will create a cycle