diff --git a/DESCRIPTION b/DESCRIPTION index 52e0d65..b42a2aa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orbweaver Title: Fast and Efficient Graph Data Structures -Version: 0.10.4 +Version: 0.11.0 Authors@R: c(person(given = "ixpantia, SRL", role = "cph", diff --git a/R/extendr-wrappers.R b/R/extendr-wrappers.R index 033b6b1..cec1a8c 100644 --- a/R/extendr-wrappers.R +++ b/R/extendr-wrappers.R @@ -50,7 +50,7 @@ DirectedGraph$nodes <- function() .Call(wrap__DirectedGraph__nodes, self) DirectedGraph$length <- function() .Call(wrap__DirectedGraph__length, self) -DirectedGraph$find_all_paths <- function(`_from`, `_to`) .Call(wrap__DirectedGraph__find_all_paths, self, `_from`, `_to`) +DirectedGraph$find_all_paths <- function(from, to) .Call(wrap__DirectedGraph__find_all_paths, self, from, to) #' @export `$.DirectedGraph` <- function (self, name) { func <- DirectedGraph[[name]]; environment(func) <- environment(); func } diff --git a/R/find_path.R b/R/find_path.R index a40aa70..63b3b1c 100644 --- a/R/find_path.R +++ b/R/find_path.R @@ -46,7 +46,7 @@ find_all_paths <- function(graph, from, to) { #' @export find_all_paths.DirectedGraph <- function(graph, from, to) { - rlang::abort("DirectedGraph does not support `find_all_paths`") + graph$find_all_paths(from, to) } #' @export diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index ebb2a40..4203eb3 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -8,18 +8,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -203,15 +191,6 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - [[package]] name = "home" version = "0.5.9" @@ -317,16 +296,15 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "orbweaver" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5188bd40db77eead2906aa2345548535a7bed89798c85bf646d07b99a823ea34" +checksum = "3fb042d43c3343b808a91c4da9924b79bb47c3ca56aa19ede98912491dceba64" dependencies = [ "flate2", "fxhash", "rayon", "serde", "serde_cbor", - "string-interner", ] [[package]] @@ -475,17 +453,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" -[[package]] -name = "string-interner" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c6a0d765f5807e98a091107bae0a56ea3799f66a5de47b2c84c94a39c09974e" -dependencies = [ - "cfg-if", - "hashbrown", - "serde", -] - [[package]] name = "syn" version = "2.0.66" @@ -509,12 +476,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "which" version = "4.4.2" @@ -630,23 +591,3 @@ checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1" dependencies = [ "winapi", ] - -[[package]] -name = "zerocopy" -version = "0.7.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index 9d55c47..0f9d6c9 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -10,7 +10,7 @@ name = 'orbweaver' [dependencies] # extendr-api = { version = "0.6", features = ["serde"] } extendr-api = { git = "https://github.com/extendr/extendr.git", rev = "cb85a21a90c3fcb538a40fcea03058454edb3dac" } -orbweaver = { version = "0.10.4" } +orbweaver = { version = "0.11.0" } # This will help us filter the platforms # we support to make the final bundle size diff --git a/src/rust/src/lib.rs b/src/rust/src/lib.rs index 7015c4c..cd87d8f 100644 --- a/src/rust/src/lib.rs +++ b/src/rust/src/lib.rs @@ -151,8 +151,13 @@ impl ImplDirectedGraph for DirectedGraph { self.0.len() as i32 } - fn find_all_paths(&self, _from: &str, _to: &str) -> Result { - todo!("Find all paths is not implemented for DirectedGraph") + fn find_all_paths(&self, from: &str, to: &str) -> Result { + Ok(self + .0 + .find_all_paths(from, to) + .map_err(to_r_error)? + .into_iter() + .collect()) } } diff --git a/src/rust/vendor.tar.xz b/src/rust/vendor.tar.xz index d365a31..506b88e 100644 Binary files a/src/rust/vendor.tar.xz and b/src/rust/vendor.tar.xz differ diff --git a/tests/testthat/test-find_path.R b/tests/testthat/test-find_path.R index 175890c..f9105c3 100644 --- a/tests/testthat/test-find_path.R +++ b/tests/testthat/test-find_path.R @@ -1,10 +1,15 @@ -test_that("find all paths on directed graph should error", { +test_that("find all paths on directed graph", { graph <- graph_builder() |> - add_edge("A", "B") |> + add_path(c("A", "B", "C")) |> + add_path(c("A", "Z", "C")) |> + add_path(c("A", "B", "A")) |> build_directed() - expect_error(find_all_paths(graph, "A", "B")) + expect_equal( + find_all_paths(graph, "A", "C"), + list(c("A", "Z", "C"), c("A", "B", "C")) + ) })