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) – Index of the parent node

  • node_b (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 for the newly created (or updated in the case of an existing edge with multigraph=False) edge.

Return type:

int