Skip to content

Commit

Permalink
Merge pull request #25 from andyquinterom/OW011
Browse files Browse the repository at this point in the history
Updates to OW 0.11
  • Loading branch information
andyquinterom authored Jun 19, 2024
2 parents 2a5a949 + e545217 commit c1cefdc
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 70 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion R/find_path.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 2 additions & 61 deletions src/rust/Cargo.lock

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

2 changes: 1 addition & 1 deletion src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ impl ImplDirectedGraph for DirectedGraph {
self.0.len() as i32
}

fn find_all_paths(&self, _from: &str, _to: &str) -> Result<List> {
todo!("Find all paths is not implemented for DirectedGraph")
fn find_all_paths(&self, from: &str, to: &str) -> Result<List> {
Ok(self
.0
.find_all_paths(from, to)
.map_err(to_r_error)?
.into_iter()
.collect())
}
}

Expand Down
Binary file modified src/rust/vendor.tar.xz
Binary file not shown.
11 changes: 8 additions & 3 deletions tests/testthat/test-find_path.R
Original file line number Diff line number Diff line change
@@ -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"))
)

})

Expand Down

0 comments on commit c1cefdc

Please sign in to comment.