Skip to content

Commit

Permalink
feat: Updates to orbweaver-rs 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andyquinterom committed Jun 12, 2024
1 parent 0ac6233 commit d37d749
Show file tree
Hide file tree
Showing 19 changed files with 435 additions and 183 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.5.7
Version: 0.6.1
Authors@R:
c(person(given = "ixpantia, SRL",
role = "cph",
Expand Down
150 changes: 138 additions & 12 deletions LICENSE.note
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,69 @@ the licenses are the same as listed here.

===============================

Name: adler
Files: vendor/adler/*
Authors: Jonas Schievink
License: 0BSD OR MIT OR Apache-2.0

------------------------------

Name: ahash
Files: vendor/ahash/*
Authors: Tom Kaitchuck
License: MIT OR Apache-2.0

------------------------------

Name: byteorder
Files: vendor/byteorder/*
Authors: Andrew Gallant
License: Unlicense OR MIT

------------------------------

Name: cfg-if
Files: vendor/cfg-if/*
Authors: Alex Crichton
License: MIT/Apache-2.0

------------------------------

Name: crc32fast
Files: vendor/crc32fast/*
Authors: Sam Rijs, Alex Crichton
License: MIT OR Apache-2.0

------------------------------

Name: crossbeam-deque
Files: vendor/crossbeam-deque/*
Authors:
License: MIT OR Apache-2.0

------------------------------

Name: crossbeam-epoch
Files: vendor/crossbeam-epoch/*
Authors:
License: MIT OR Apache-2.0

------------------------------

Name: crossbeam-utils
Files: vendor/crossbeam-utils/*
Authors:
License: MIT OR Apache-2.0

------------------------------

Name: either
Files: vendor/either/*
Authors: bluss
License: MIT OR Apache-2.0

------------------------------

Name: extendr-api
Files: vendor/extendr-api/*
Authors: andy-thomason, Thomas Down, Mossa Merhi Reimert, Claus O. Wilke, Hiroaki Yutani, Ilia A. Kosenkov, Michael Milton
Expand All @@ -29,9 +92,30 @@ License: MIT

------------------------------

Name: itoa
Files: vendor/itoa/*
Authors: David Tolnay
Name: flate2
Files: vendor/flate2/*
Authors: Alex Crichton, Josh Triplett
License: MIT OR Apache-2.0

------------------------------

Name: fxhash
Files: vendor/fxhash/*
Authors: cbreeden
License: Apache-2.0/MIT

------------------------------

Name: half
Files: vendor/half/*
Authors: Kathryn Long
License: MIT OR Apache-2.0

------------------------------

Name: hashbrown
Files: vendor/hashbrown/*
Authors: Amanieu d'Antras
License: MIT OR Apache-2.0

------------------------------
Expand All @@ -43,6 +127,13 @@ License: MIT

------------------------------

Name: miniz_oxide
Files: vendor/miniz_oxide/*
Authors: Frommi, oyvindln
License: MIT OR Zlib OR Apache-2.0

------------------------------

Name: once_cell
Files: vendor/once_cell/*
Authors: Aleksey Kladov
Expand Down Expand Up @@ -78,22 +169,29 @@ License: MIT OR Apache-2.0

------------------------------

Name: ryu
Files: vendor/ryu/*
Authors: David Tolnay
License: Apache-2.0 OR BSL-1.0
Name: rayon-core
Files: vendor/rayon-core/*
Authors: Niko Matsakis, Josh Stone
License: MIT OR Apache-2.0

------------------------------

Name: serde_derive
Files: vendor/serde_derive/*
Authors: Erick Tryzelaar, David Tolnay
Name: rayon
Files: vendor/rayon/*
Authors: Niko Matsakis, Josh Stone
License: MIT OR Apache-2.0

------------------------------

Name: serde_json
Files: vendor/serde_json/*
Name: serde_cbor
Files: vendor/serde_cbor/*
Authors: Pyfisch, Steven Fackler
License: MIT/Apache-2.0

------------------------------

Name: serde_derive
Files: vendor/serde_derive/*
Authors: Erick Tryzelaar, David Tolnay
License: MIT OR Apache-2.0

Expand All @@ -106,6 +204,13 @@ License: MIT OR Apache-2.0

------------------------------

Name: string-interner
Files: vendor/string-interner/*
Authors: Robbepop
License: MIT/Apache-2.0

------------------------------

Name: syn
Files: vendor/syn/*
Authors: David Tolnay
Expand All @@ -117,3 +222,24 @@ Name: unicode-ident
Files: vendor/unicode-ident/*
Authors: David Tolnay
License: (MIT OR Apache-2.0) AND Unicode-DFS-2016

------------------------------

Name: version_check
Files: vendor/version_check/*
Authors: Sergio Benitez
License: MIT/Apache-2.0

------------------------------

Name: zerocopy-derive
Files: vendor/zerocopy-derive/*
Authors: Joshua Liebow-Feeser
License: BSD-2-Clause OR Apache-2.0 OR MIT

------------------------------

Name: zerocopy
Files: vendor/zerocopy/*
Authors: Joshua Liebow-Feeser
License: BSD-2-Clause OR Apache-2.0 OR MIT
6 changes: 2 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ S3method(get_leaves_under,DirectedAcyclicGraph)
S3method(get_leaves_under,DirectedGraph)
S3method(get_roots_over,DirectedAcyclicGraph)
S3method(get_roots_over,DirectedGraph)
S3method(graph_to_json,DirectedAcyclicGraph)
S3method(graph_to_json,DirectedGraph)
S3method(has_children,DirectedAcyclicGraph)
S3method(has_children,DirectedGraph)
S3method(has_parents,DirectedAcyclicGraph)
Expand Down Expand Up @@ -49,8 +47,8 @@ export(get_all_roots)
export(get_leaves_under)
export(get_roots_over)
export(graph_builder)
export(graph_from_json)
export(graph_to_json)
export(graph_from_bin)
export(graph_to_bin)
export(has_children)
export(has_parents)
export(least_common_parents)
Expand Down
37 changes: 37 additions & 0 deletions R/bin.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#' @title Save the graph into a binary blob
#' @param graph A graph object
#' @param path Path to a file to save the graph into
#' @return Run for its side-effects
#' @export
graph_to_bin <- function(graph, path) {
if (missing(path)) {
return(graph$to_bin_mem())
}
graph$to_bin_disk(path)
}

#' @title Read the graph from a binary blob
#' @param path Path to a file containing a graph binary
#' @param type The type of graph the JSON represents
#' @return A graph object
#' @export
graph_from_bin <- function(path, bin, type = c("directed", "dag")) {
if (!type[1] %in% c("directed", "dag")) {
rlang::abort("Invalid argument `type`")
}
if (!missing(bin)) {
switch(
type[1],
"directed" = DirectedGraph$from_bin_mem(bin),
"dag" = DirectedAcyclicGraph$from_bin_mem(bin)
)
}
if (missing(path)) {
rlang::abort("Must provide `path` or `bin` arguments")
}
switch(
type[1],
"directed" = DirectedGraph$from_bin_disk(path),
"dag" = DirectedAcyclicGraph$from_bin_disk(path)
)
}
4 changes: 2 additions & 2 deletions R/builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ graph_builder <- function(type = "directed") {
#' @export
add_edge <- function(graph_builder, from, to) {
graph_builder$add_edge(from, to)
return(graph_builder)
}

#' @title Add a path to a graph
Expand All @@ -27,14 +28,13 @@ add_edge <- function(graph_builder, from, to) {
#' Adds all of the edges that make up the given
#' path to the graph.
#'
#' NOTE: Not all graphs are able to be modified.
#'
#' @param graph_builder A graph builder_object
#' @param path A character vector that describes the path
#' @return The updated graph builder object
#' @export
add_path <- function(graph_builder, path) {
graph_builder$add_path(path)
return(graph_builder)
}

#' @title Build a DirectedGraph from a builder
Expand Down
24 changes: 16 additions & 8 deletions R/extendr-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ NULL

rs_populate_edges_builder <- function(graph, parent_iter, child_iter) .Call(wrap__rs_populate_edges_builder, graph, parent_iter, child_iter)

rs_directed_graph_from_json <- function(text) .Call(wrap__rs_directed_graph_from_json, text)

rs_directed_graph_to_json <- function(directed_graph, pretty) .Call(wrap__rs_directed_graph_to_json, directed_graph, pretty)

rs_dag_to_json <- function(dag, pretty) .Call(wrap__rs_dag_to_json, dag, pretty)

rs_dag_from_json <- function(text) .Call(wrap__rs_dag_from_json, text)

DirectedGraph <- new.env(parent = emptyenv())

DirectedGraph$find_path <- function(from, to) .Call(wrap__DirectedGraph__find_path, self, from, to)
Expand Down Expand Up @@ -49,6 +41,14 @@ DirectedGraph$print <- function() invisible(.Call(wrap__DirectedGraph__print, se

DirectedGraph$find_all_paths <- function(`_from`, `_to`) .Call(wrap__DirectedGraph__find_all_paths, self, `_from`, `_to`)

DirectedGraph$to_bin_disk <- function(path) .Call(wrap__DirectedGraph__to_bin_disk, self, path)

DirectedGraph$to_bin_mem <- function() .Call(wrap__DirectedGraph__to_bin_mem, self)

DirectedGraph$from_bin_disk <- function(path) .Call(wrap__DirectedGraph__from_bin_disk, path)

DirectedGraph$from_bin_mem <- function(bin) .Call(wrap__DirectedGraph__from_bin_mem, bin)

#' @export
`$.DirectedGraph` <- function (self, name) { func <- DirectedGraph[[name]]; environment(func) <- environment(); func }

Expand Down Expand Up @@ -83,6 +83,14 @@ DirectedAcyclicGraph$print <- function() invisible(.Call(wrap__DirectedAcyclicGr

DirectedAcyclicGraph$find_all_paths <- function(from, to) .Call(wrap__DirectedAcyclicGraph__find_all_paths, self, from, to)

DirectedAcyclicGraph$to_bin_disk <- function(path) .Call(wrap__DirectedAcyclicGraph__to_bin_disk, self, path)

DirectedAcyclicGraph$to_bin_mem <- function() .Call(wrap__DirectedAcyclicGraph__to_bin_mem, self)

DirectedAcyclicGraph$from_bin_disk <- function(path) .Call(wrap__DirectedAcyclicGraph__from_bin_disk, path)

DirectedAcyclicGraph$from_bin_mem <- function(bin) .Call(wrap__DirectedAcyclicGraph__from_bin_mem, bin)

#' @export
`$.DirectedAcyclicGraph` <- function (self, name) { func <- DirectedAcyclicGraph[[name]]; environment(func) <- environment(); func }

Expand Down
34 changes: 0 additions & 34 deletions R/json.R

This file was deleted.

Loading

0 comments on commit d37d749

Please sign in to comment.