-
Notifications
You must be signed in to change notification settings - Fork 193
Add insert_node_on_in_edges and insert_node_on_out_edges methods #181
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
Conversation
This commit adds 2 new methods to the PyDiGraph class, insert_node_between() and insert_node_between_multiple. These methods are for inserting edges between a node and another node that has edges. You specify a node and which node to insert it between and it will loop over either the incoming or outgoing edges and add edges between the existing edges.
Marking as on hold because I need to add more unittests to improve the coverage, and also add more than the simple cases. |
This commit migrates the inner loop for apply_operation_back and apply_operation_front to leverage retworkx's insert_node_between_multiple PyDiGraph method. This retworkx method performs essentially the same loop internally but executes faster. Depends on Qiskit/rustworkx#181 being included in a release.
Pull Request Test Coverage Report for Build 355266041
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to #147, I think it would be better to have insert_node_on_in_edges(node, node_ref)
and insert_node_on_out_edges
rather than unified insert_node_between(node, node_ref, direction)
. What do you think?
Yeah that's a good idea. I'll update it shortly to split the functions |
This commit splits the new methods into separate and better named ones per @itoko's excellent suggestion. The insert_node_between method becomes insert_node_on_in_edges and insert_node_on_out_edges, and insert_node_between_multiple becomes insert_node_on_in_edges_multiple and insert_node_on_out_edges_multiple. The direction kwarg is also removed from the Python API.
@mtreinish Thank you. I have one more comment on docstrings. I think we can describe the spec more clearly without parent/child notation:
(I like the term BTW, I personally prefer |
@itoko thank you for the suggestions. I was actually hoping you'd leave a comment like that. I thought the names were awkward in this function, but couldn't come up with anything better so just left it as is. I'll update it now per your suggestions. |
Co-authored-by: Toshinari Itoko <itoko@jp.ibm.com>
* Leverage retworkx for apply_operation* inner loop This commit migrates the inner loop for apply_operation_back and apply_operation_front to leverage retworkx's insert_node_between_multiple PyDiGraph method. This retworkx method performs essentially the same loop internally but executes faster. Depends on Qiskit/rustworkx#181 being included in a release. * DNM: Test with retworkx branch * Update for retworkx 0.6.0 release * Remove stray kwarg from earlier revision Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit adds 2 new methods to the PyDiGraph class,
insert_node_between() and insert_node_between_multiple. These methods
are for inserting edges between a node and another node that has edges.
You specify a node and which node to insert it between and it will loop
over either the incoming or outgoing edges and add edges between the
existing edges.