-
Notifications
You must be signed in to change notification settings - Fork 214
Implementation of cycle_basis_edges #885
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
Open
raynelfss
wants to merge
34
commits into
Qiskit:main
Choose a base branch
from
raynelfss:cycle_basis_edges
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
62f26f9
Initial implementation of cycle_basis_edges
raynelfss 35eea7e
Hotfix: DocTest now passes
raynelfss a8c1b67
Correction: Function returns EdgeIndex
raynelfss c22c0b5
Docs: Added release note
raynelfss c6dea4e
CI: Added python tests to test_cycle_basis.py
raynelfss 23f2759
Correction: get_edge_between checks target only
raynelfss dadb482
Feature: merge basis and basis_edges into one
raynelfss 50d8685
CI: Modify python tests for new changes
raynelfss 7c45634
Docs: made changes to releasenotes and api.rst
raynelfss c0f9f94
Fix: Make `cycle_basis` and `EdgeOrNode` private
raynelfss df5b3b5
CI: Modify python tests for new changes
raynelfss 26146af
Docs: Fixed release notes with the latest changes
raynelfss f3f271a
Correction: remove redundant self-loop check
raynelfss 70541c8
Docs: Add upgrade release note
raynelfss dc7eb26
Correction: `get_edge_between` returns `EdgeId`.
raynelfss 38bdeac
Docs: Removed fix section of docstring.
raynelfss 075b2f0
Docs: Removed old api.rst file
raynelfss 151a314
Fix: Pop unwrap warning by clippy.
raynelfss 7f52970
Merge branch 'main' into cycle_basis_edges
raynelfss 10c16bf
Merge branch 'main' into cycle_basis_edges
raynelfss 62169b4
Merge branch 'main' into cycle_basis_edges
raynelfss 6d11293
Merge branch 'main' into cycle_basis_edges
raynelfss bcf8ce1
Merge remote-tracking branch 'upstream/main' into cycle_basis_edges
raynelfss cdb4a3b
Lint: Fix typos
raynelfss f8d7ba0
Lint: Fix indentation
raynelfss b822777
Lint: Fix yet another indentation issue
raynelfss a44c7e8
Fix: Add missing stubs
raynelfss 54e7009
Merge branch 'main' into cycle_basis_edges
raynelfss 09d366b
Merge branch 'main' into cycle_basis_edges
raynelfss c61019b
Rebalance `cycle_basis` pipeline
raynelfss dc66547
FIx: Relax trait bounds for functions
raynelfss 04112e3
Apply suggestions from code review
raynelfss bcf5548
Move comment back to original position
raynelfss 70bbdd3
Rename `cycle_filter` as `cycle_builder`
raynelfss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
56 changes: 56 additions & 0 deletions
56
releasenotes/notes/add-cycle-basis-edges-5cb31eac7e41096d.yaml
This file contains hidden or 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,56 @@ | ||
| --- | ||
| features: | ||
| - | | ||
| A function, ``cycle_basis_edges`` was added to the crate | ||
| ``rustworkx-core`` in the ``connectivity`` module. This function returns | ||
| the edge indices that form the cycle basis of a graph. | ||
| - | | ||
| Added a new function :func:`~rustworkx.cycle_basis_edges` which is similar | ||
| to the existing :func:`~.cycle_basis` function but instead of returning node | ||
| indices it returns a list of edge indices for the cycle. | ||
|
|
||
| .. jupyter-execute:: | ||
|
|
||
| import rustworkx | ||
| from rustworkx.visualization import * # Needs matplotlib/ | ||
|
|
||
| graph = rustworkx.PyGraph() | ||
|
|
||
| # Each time add node is called, it returns a new node index | ||
| a = graph.add_node("A") | ||
| b = graph.add_node("B") | ||
| c = graph.add_node("C") | ||
| d = graph.add_node("D") | ||
| e = graph.add_node("E") | ||
| f = graph.add_node("F") | ||
| g = graph.add_node("G") | ||
| h = graph.add_node("H") | ||
| i = graph.add_node("I") | ||
| j = graph.add_node("J") | ||
|
|
||
| # add_edges_from takes tuples of node indices and weights, | ||
| # and returns edge indices | ||
| graph.add_edges_from([ | ||
| (a, b, 1.5), | ||
| (a, a, 1.0), | ||
| (a, c, 5.0), | ||
| (b, c, 2.5), | ||
| (c, d, 1.3), | ||
| (d, e, 0.8), | ||
| (e, f, 1.6), | ||
| (f, d, 0.7), | ||
| (e, g, 0.7), | ||
| (g, h, 0.9), | ||
| (g, i, 1.0), | ||
| (i, j, 0.8), | ||
| ]) | ||
|
|
||
| mpl_draw(graph, with_labels=True) | ||
| # Retrieve EdgeIDs by enabling the edges flag. | ||
| cycles_edges = rustworkx.cycle_basis_edges(graph, a) | ||
| edge_list = list(graph.edge_list()) | ||
| cycle_info = [[graph.get_edge_data_by_index(edge) for edge in cycle] for cycle in cycles_edges] | ||
| # Print the EdgeID's that form cycles in the graph | ||
| display(cycles_edges) | ||
| # Print the data retrieved from the graph. | ||
| display(cycle_info) |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.