Skip to content

Commit

Permalink
Add token swapper to rustworkx-core (#765)
Browse files Browse the repository at this point in the history
* Add token swapper

* Finish add_token_edges setup rand

* Finish main fn

* Add swap fn

* Add find_cycle and start trial_map

* Finish good compile code

* First testing

* Rebuild swapper using struct and impl

* Restructure around struct and token_swapper

* Fix find_cycle and passing copies

* First test success and cleanup

* More testing and simplify di and sub_di graph

* Finish tests

* Format

* Lint

* Add python interface

* Fix limit calc

* Fix pyo3 signature

* One more time

* pyo3 fix

* Fix signature 2

* Add python tests

* Cleanup and reno

* Fix conflict

* Use connectivity::find_cycle

* Review updates

* Switch to map

* Convert trial_map to parallel

* Fix seed changes

* Cleanup and comments

* Name changes

* Finish docs and add threshold

* Fix stable graph removed nodes and error msgs

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
enavarro51 and mergify[bot] authored Apr 18, 2023
1 parent 8786c41 commit 7ed0f1f
Show file tree
Hide file tree
Showing 9 changed files with 811 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ typed API based on the data type.
rustworkx.graph_complement
rustworkx.graph_union
rustworkx.graph_tensor_product
rustworkx.graph_token_swapper
rustworkx.graph_cartesian_product
rustworkx.graph_random_layout
rustworkx.graph_bipartite_layout
Expand Down
6 changes: 6 additions & 0 deletions releasenotes/notes/added-token-swapper-bd168eeb5a31bd99.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
features:
- |
Added a new function, :func:`~.token_swapper()` which performs an
approximately optimal Token Swapping algorithm and supports partial
mappings (i.e. not-permutations) for graphs with missing tokens.
2 changes: 2 additions & 0 deletions rustworkx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ keywords = ["graph"]
ahash = "0.8.0"
fixedbitset = "0.4.2"
petgraph = "0.6.3"
rand = "0.8.5"
rand_pcg = "0.3.1"
rayon = "1.6"
num-traits = "0.2"
priority-queue = "1.2"
Expand Down
3 changes: 3 additions & 0 deletions rustworkx-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
//! * [`connectivity`](./connectivity/index.html)
//! * [`max_weight_matching`](./max_weight_matching/index.html)
//! * [`shortest_path`](./shortest_path/index.html)
//! * [`token_swapper`](./token_swapper/index.html)
//! * [`traversal`](./traversal/index.html)
//! * [`generators`](./generators/index.html)
//!
Expand Down Expand Up @@ -82,6 +83,8 @@ pub mod traversal;
pub mod dictmap;
pub mod distancemap;
mod min_scored;
/// Module for swapping tokens
pub mod token_swapper;
pub mod utils;

// re-export petgraph so there is a consistent version available to users and
Expand Down
Loading

0 comments on commit 7ed0f1f

Please sign in to comment.