forked from Qiskit/rustworkx
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes
digraph_union
if merge_edges
is set to true.
Previously, `digraph_union` would falsely keep or delete edges if `merge_edges` is set to true. This commit fixes the logic of `digraph_union` to skip an edge from the second graph if both its endpoints were merged to nodes from the first graph and these nodes already share an edge with equal weight data. At the same time, a new function `graph_union` was added that returns the union of two `PyGraph`s. Closes Qiskit#432.
- Loading branch information
1 parent
f2f3a09
commit f9b0050
Showing
6 changed files
with
288 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
fixes: | ||
- | | ||
Previously, :func:`~retworkx.digraph_union` would falsely keep or delete edges | ||
if argument `merge_edges` is set to true. This has been fixed and an edge from | ||
the second graph will be skipped if both its endpoints were merged to nodes from | ||
the first graph and these nodes already share an edge with equal weight data. | ||
Fixed `#432 <https://github.com/Qiskit/retworkx/issues/432>`__ | ||
features: | ||
- | | ||
Adds a new function :func:`~retworkx.graph_union` that returns the union | ||
of two :class:`~retworkx.PyGraph` objects. | ||
For example: | ||
.. jupyter-execute:: | ||
import retworkx | ||
from retworkx.visualization import mpl_draw | ||
first = retworkx.generators.path_graph(3, weights=["a_0", "node", "a_1"]) | ||
second = retworkx.generators.cycle_graph(3, weights=["node", "b_0", "b_1"]) | ||
graph = retworkx.graph_union(first, second, merge_nodes=True) | ||
mpl_draw(graph) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.