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.PyGraph.add_edge#

PyGraph.add_edge(node_a, node_b, edge, /)#

Add an edge between 2 nodes.

If multigraph is False and an edge already exists between node_a and node_b the weight/payload of that existing edge will be updated to be edge.

Parameters:
  • node_a (int) – The index of the parent node

  • node_b (int) – The index of the child node

  • edge (T) – The python object to attach to the edge

Returns:

The index of the newly created (or updated in the case of an existing edge with multigraph=False) edge.

Return type:

int