rustworkx.PyDAG.merge_nodes#

PyDAG.merge_nodes(u, v, /)#

Merge two nodes in the graph.

If the nodes have equal weight objects then all the edges into and out of u will be added to v and u will be removed from the graph. If the nodes don’t have equal weight objects then no changes will be made and no error raised

Parameters:
  • u (int) – The source node that is going to be merged

  • v (int) – The target node that is going to be the new node