By default, all graphs in rustworkx are multigraphs, meaning they allow parallel edges between the same two nodes.
To prevent parallel edges, set the multigraph argument to False in the PyGraph or PyDiGraph constructors. When multigraph=False, any attempt to add a parallel edge will instead update the existing edge's weight or data payload rather than creating a new edge.
import rustworkx as rx
graph = rx.PyGraph(multigraph=False)
graph.add_nodes_from(range(3))
graph.add_edges_from([(0, 1, 'A'), (0, 1, 'B'), (1, 2, 'C')])
# The edge between 0 and 1 will have the payload 'B', not both 'A' and 'B'.