New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
digraph_union
fails if merge_edges
is set to true
#432
Comments
Oh, actually i'm a bit confused now. I was ready to push a fix for this but then i realized i am not sure what's the expected output for this function. I was under the impression that @mtreinish Any input on this? |
Yeah, I'm not sure exactly what the intent there is, based on that test it looks like it combines the edges if they're between nodes with the same weights and they have the same edge weight. Which seems a bit unexpected, like if the nodes aren't combined how do we know which edge to keep (just the first graph's)? |
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.
* 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>
Information
What is the current behavior?
If
merge_edges
arg is set toTrue
,digraph_union
returns wrong output. This happens in many cases (e.g graphs with node holes, mismatch edge weights) and this means we need to rework the logic of the function.What is the expected behavior?
Fix this.
Steps to reproduce the problem
An example where an edge is deleted when it shouldn't since edge weights don't match:
An example with node index hole where an edge is not deleted but it should be removed.
The text was updated successfully, but these errors were encountered: