Skip to content
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

Implementation of cycle_basis_edges #885

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
62f26f9
Initial implementation of cycle_basis_edges
raynelfss May 31, 2023
35eea7e
Hotfix: DocTest now passes
raynelfss May 31, 2023
a8c1b67
Correction: Function returns EdgeIndex
raynelfss Jun 1, 2023
c22c0b5
Docs: Added release note
raynelfss Jun 1, 2023
c6dea4e
CI: Added python tests to test_cycle_basis.py
raynelfss Jun 2, 2023
23f2759
Correction: get_edge_between checks target only
raynelfss Jun 2, 2023
dadb482
Feature: merge basis and basis_edges into one
raynelfss Jun 6, 2023
50d8685
CI: Modify python tests for new changes
raynelfss Jun 6, 2023
7c45634
Docs: made changes to releasenotes and api.rst
raynelfss Jun 6, 2023
c0f9f94
Fix: Make `cycle_basis` and `EdgeOrNode` private
raynelfss Jun 8, 2023
df5b3b5
CI: Modify python tests for new changes
raynelfss Jun 8, 2023
26146af
Docs: Fixed release notes with the latest changes
raynelfss Jun 8, 2023
f3f271a
Correction: remove redundant self-loop check
raynelfss Jun 12, 2023
70541c8
Docs: Add upgrade release note
raynelfss Jun 12, 2023
dc7eb26
Correction: `get_edge_between` returns `EdgeId`.
raynelfss Jun 19, 2023
38bdeac
Docs: Removed fix section of docstring.
raynelfss Jul 11, 2023
075b2f0
Docs: Removed old api.rst file
raynelfss Aug 11, 2023
151a314
Fix: Pop unwrap warning by clippy.
raynelfss Aug 11, 2023
7f52970
Merge branch 'main' into cycle_basis_edges
raynelfss Aug 12, 2023
10c16bf
Merge branch 'main' into cycle_basis_edges
raynelfss Aug 23, 2023
62169b4
Merge branch 'main' into cycle_basis_edges
raynelfss Dec 14, 2023
6d11293
Merge branch 'main' into cycle_basis_edges
raynelfss Jul 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Connectivity and Cycles
rustworkx.weakly_connected_components
rustworkx.is_weakly_connected
rustworkx.cycle_basis
rustworkx.cycle_basis_edges
rustworkx.simple_cycles
rustworkx.digraph_find_cycle
rustworkx.articulation_points
Expand Down
61 changes: 61 additions & 0 deletions releasenotes/notes/add-cycle-basis-edges-5cb31eac7e41096d.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
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 = [[edge_list[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)
upgrade:
- |
The trait bounds of :func:`rustworkx_core::connectivity::cycle_basis` now
requires graphs to be compatible with the trait ``IntoEdges`` and that the
attribute ``EdgeId`` conforms to `Eq` and `Hash`.
Loading
Loading