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 #432. * increase test cov * improve release note and message in panic exception Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * add dispatch function `union` and implement `find_node_by_weight` for `PyGraph` * lint * Release note fixes Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
- Loading branch information
1 parent
f2f3a09
commit 466b884
Showing
9 changed files
with
434 additions
and
140 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,33 @@ | ||
--- | ||
fixes: | ||
- | | ||
Previously, :func:`~retworkx.digraph_union` would incorrectly 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: | ||
- | | ||
Add a new function :func:`~retworkx.graph_union` that returns the union | ||
of two :class:`~retworkx.PyGraph` objects. This is the equivalent to | ||
:func:`~retworkx.digraph_union` but for a :class:`~retworkx.PyGraph` | ||
instead of for a :class:`~retworkx.PyDiGraph`. A new unified function | ||
:func:`~retworkx.union` was also added that supports both | ||
:class:`~retworkx.PyDiGraph` and :class:`~retworkx.PyGraph`. | ||
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) | ||
- | | ||
The kwargs ``merge_nodes`` and ``merge_edges`` of :func:`~retworkx.digraph_union` are | ||
now optional and by default are set `False`. | ||
- | | ||
Add a new :meth:`~retworkx.PyGraph.find_node_by_weight` that finds the index | ||
of a node given a specific weight. |
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
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.