Warning
The documentation for retworkx has migrated to:
https://qiskit.org/documentation/retworkx
These docs will no longer be updated.
retworkx.digraph_union¶
- digraph_union(first, second, merge_nodes, merge_edges, /)¶
Return a new PyDiGraph by forming a union from two input PyDiGraph objects
The algorithm in this function operates in three phases:
Add all the nodes from
secondintofirst. operates in O(n), with n being number of nodes in b.Merge nodes from
secondoverfirstgiven that:The
merge_nodesisTrue. operates in O(n^2), with n being the number of nodes insecond.The respective node in
secondandfirstshare the same weight/data payload.
Adds all the edges from
secondtofirst. If themerge_edgesparameter isTrueand the respective edge insecondand first`` share the same weight/data payload they will be merged together.
- param PyDiGraph first
The first directed graph object
- param PyDiGraph second
The second directed graph object
- param bool merge_nodes
If set to
Truenodes will be merged betweensecondandfirstif the weights are equal.- param bool merge_edges
If set to
Trueedges will be merged betweensecondandfirstif the weights are equal.- returns
A new PyDiGraph object that is the union of
secondandfirst. It’s worth noting the weight/data payload objects are passed by reference fromfirstandsecondto this new object.- rtype
PyDiGraph