-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from andyquinterom/T19
Updates to orbweaver-rs 0.2.1
- Loading branch information
Showing
89 changed files
with
2,054 additions
and
1,049 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
^check$ | ||
|
||
^update_authors\.R$ | ||
^src/\.cargo$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,5 @@ src/rust/.cargo | |
src/rust/vendor/ | ||
|
||
docs | ||
.vscode | ||
.vscode | ||
src/rust/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.PHONY: vendor document | ||
|
||
vendor: | ||
$(MAKE) -C src/rust vendor | ||
|
||
document: | ||
Rscript -e "rextendr::document()" | ||
|
||
install: document | ||
Rscript -e "devtools::install()" | ||
|
||
test: | ||
Rscript -e "devtools::test()" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,83 @@ | ||
# Generated by roxygen2: do not edit by hand | ||
|
||
S3method("$",AcyclicGraph) | ||
S3method("[[",AcyclicGraph) | ||
S3method(as.list,AcyclicGraph) | ||
S3method(as_graph,data.frame) | ||
export(add_child) | ||
S3method("$",DirectedAcyclicGraph) | ||
S3method("$",DirectedGraph) | ||
S3method("$",Node) | ||
S3method("[[",DirectedAcyclicGraph) | ||
S3method("[[",DirectedGraph) | ||
S3method("[[",Node) | ||
S3method(add_edge,DirectedAcyclicGraph) | ||
S3method(add_edge,DirectedGraph) | ||
S3method(add_node,DirectedAcyclicGraph) | ||
S3method(add_node,DirectedGraph) | ||
S3method(add_path,DirectedAcyclicGraph) | ||
S3method(add_path,DirectedGraph) | ||
S3method(clear_edges,DirectedAcyclicGraph) | ||
S3method(clear_edges,DirectedGraph) | ||
S3method(deep_clone,DirectedAcyclicGraph) | ||
S3method(deep_clone,DirectedGraph) | ||
S3method(edge_exists,DirectedAcyclicGraph) | ||
S3method(edge_exists,DirectedGraph) | ||
S3method(find_all_paths,DirectedAcyclicGraph) | ||
S3method(find_all_paths,DirectedGraph) | ||
S3method(find_path,DirectedAcyclicGraph) | ||
S3method(find_path,DirectedGraph) | ||
S3method(get_children,DirectedAcyclicGraph) | ||
S3method(get_children,DirectedGraph) | ||
S3method(get_leaves,DirectedGraph) | ||
S3method(get_node,DirectedAcyclicGraph) | ||
S3method(get_node,DirectedGraph) | ||
S3method(get_node_data,Node) | ||
S3method(get_nodes,DirectedAcyclicGraph) | ||
S3method(get_nodes,DirectedGraph) | ||
S3method(get_parents,DirectedAcyclicGraph) | ||
S3method(get_parents,DirectedGraph) | ||
S3method(graph_to_json,DirectedAcyclicGraph) | ||
S3method(graph_to_json,DirectedGraph) | ||
S3method(has_children,DirectedAcyclicGraph) | ||
S3method(has_children,DirectedGraph) | ||
S3method(has_parents,DirectedAcyclicGraph) | ||
S3method(has_parents,DirectedGraph) | ||
S3method(into_dag,DirectedAcyclicGraph) | ||
S3method(into_dag,DirectedGraph) | ||
S3method(into_directed,DirectedAcyclicGraph) | ||
S3method(into_directed,DirectedGraph) | ||
S3method(least_common_parents,AcyclicDirectedGraph) | ||
S3method(least_common_parents,DirectedGraph) | ||
S3method(populate_edges,DirectedAcyclicGraph) | ||
S3method(populate_edges,DirectedGraph) | ||
S3method(populate_nodes,DirectedAcyclicGraph) | ||
S3method(populate_nodes,DirectedGraph) | ||
S3method(remove_edge,DirectedAcyclicGraph) | ||
S3method(remove_edge,DirectedGraph) | ||
S3method(remove_node,DirectedAcyclicGraph) | ||
S3method(remove_node,DirectedGraph) | ||
S3method(set_node_data,Node) | ||
export(add_edge) | ||
export(add_node) | ||
export(as_graph) | ||
export(clone_graph) | ||
export(filter_tree) | ||
export(add_path) | ||
export(clear_edges) | ||
export(deep_clone) | ||
export(edge_exists) | ||
export(find_all_paths) | ||
export(find_least_common_parents) | ||
export(find_leaves) | ||
export(find_roots) | ||
export(find_path) | ||
export(get_children) | ||
export(get_leaves) | ||
export(get_node) | ||
export(get_node_data) | ||
export(get_nodes) | ||
export(get_parents) | ||
export(new_graph) | ||
export(search_for_node) | ||
export(graph_from_json) | ||
export(graph_to_json) | ||
export(has_children) | ||
export(has_parents) | ||
export(into_dag) | ||
export(into_directed) | ||
export(least_common_parents) | ||
export(new_directed_graph) | ||
export(populate_edges) | ||
export(populate_nodes) | ||
export(remove_edge) | ||
export(remove_node) | ||
export(set_node_data) | ||
useDynLib(orbweaver, .registration = TRUE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' @title Add an edge to a graph | ||
#' | ||
#' @description | ||
#' Adds an edge from one node to another in a | ||
#' a directed graph. | ||
#' | ||
#' NOTE: Not all graphs are able to be modified. | ||
#' | ||
#' @param graph A graph object | ||
#' @param from The id of the `from` node. | ||
#' @param to The id of the `to` node. | ||
#' @return The updated graph object | ||
#' @export | ||
add_edge <- function(graph, from, to) { | ||
UseMethod("add_edge") | ||
} | ||
|
||
#' @export | ||
add_edge.DirectedGraph <- function(graph, from, to) { | ||
graph$add_edge(from, to) | ||
return(graph) | ||
} | ||
|
||
#' @export | ||
add_edge.DirectedAcyclicGraph <- function(graph, from, to) { | ||
rlang::abort(err_unable_to_modify_dag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' @title Add a new node to a graph | ||
#' | ||
#' @description | ||
#' Appends a new node to the graph in-place with | ||
#' some arbitrary data. | ||
#' | ||
#' NOTE: Not all graphs are able to be modified. | ||
#' | ||
#' @param graph A graph object | ||
#' @param node_id The unique id of the node to be added | ||
#' @param data R object to be used as the data for the node | ||
#' @return The updated graph object | ||
#' @export | ||
add_node <- function(graph, node_id, data = NULL) { | ||
UseMethod("add_node") | ||
} | ||
|
||
#' @export | ||
add_node.DirectedGraph <- function(graph, node_id, data = NULL) { | ||
graph$add_node(node_id, data) | ||
return(graph) | ||
} | ||
|
||
#' @export | ||
add_node.DirectedAcyclicGraph <- function(graph, node_id, data = NULL) { | ||
rlang::abort(err_unable_to_modify_dag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#' @title Add a path to a graph | ||
#' | ||
#' @description | ||
#' 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 A graph object | ||
#' @param path A character vector that describes the path | ||
#' @return The updated graph object | ||
#' @export | ||
add_path <- function(graph, path) { | ||
UseMethod("add_path") | ||
} | ||
|
||
#' @export | ||
add_path.DirectedGraph <- function(graph, path) { | ||
graph$add_path(path) | ||
return(graph) | ||
} | ||
|
||
#' @export | ||
add_path.DirectedAcyclicGraph <- function(graph, path) { | ||
rlang::abort(err_unable_to_modify_dag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#' @title Populates the edges of a graph from a `tibble` | ||
#' @description Adds a set of edges from a `tibble` to a graph | ||
#' @param graph A graph object | ||
#' @param edges_df A `tibble` with a parent and child variable | ||
#' @param parent_col The name of the column containing the parents | ||
#' @param child_col The name of the column containing the children | ||
#' @return The updated graph object | ||
#' @export | ||
populate_edges <- function(graph, edges_df, parent_col, child_col) { | ||
UseMethod("populate_edges") | ||
} | ||
|
||
#' @export | ||
populate_edges.DirectedGraph <- function(graph, edges_df, parent_col, child_col) { | ||
|
||
parent_iter <- edges_df[[parent_col]] | ||
if (!is.character(parent_iter)) { | ||
rlang::abort(glue::glue("Column {parent_col} is not of class `character`")) | ||
} | ||
|
||
child_iter <- edges_df[[child_col]] | ||
if (!is.character(child_iter)) { | ||
rlang::abort(glue::glue("Column {child_col} is not of class `character`")) | ||
} | ||
|
||
rs_populate_edges_directed_graph(graph, parent_iter, child_iter) | ||
return(graph) | ||
} | ||
|
||
#' @export | ||
populate_edges.DirectedAcyclicGraph <- function(graph, edges_df, parent_col, child_col) { | ||
rlang::abort(err_unable_to_modify_dag) | ||
} | ||
|
||
#' @title Populates the nodes of a graph from a `tibble` | ||
#' @description Adds a set of nodes from a `tibble` to a graph | ||
#' @param graph A graph object | ||
#' @param nodes_df A `tibble` with a node id and data column | ||
#' @param node_id_col The name of the column containing the node ids | ||
#' @param data_col The name of the column containing the data of the nodes | ||
#' @return The updated graph object | ||
#' @export | ||
populate_nodes <- function(graph, nodes_df, node_id_col, data_col = NULL) { | ||
UseMethod("populate_nodes") | ||
} | ||
|
||
#' @export | ||
populate_nodes.DirectedGraph <- function(graph, nodes_df, node_id_col, data_col = NULL) { | ||
|
||
node_ids <- nodes_df[[node_id_col]] | ||
if (!is.character(node_ids)) { | ||
rlang::abort(glue::glue("Column {node_id_col} is not of class `character`")) | ||
} | ||
|
||
data_iter <- NULL | ||
|
||
if (!is.null(data_col)) { | ||
data_iter <- as.list(nodes_df[[data_col]]) | ||
} | ||
|
||
rs_populate_nodes_directed_graph(graph, node_ids, data_iter) | ||
return(graph) | ||
} | ||
|
||
#' @export | ||
populate_nodes.DirectedAcyclicGraph <- function(graph, nodes_df, node_id_col, data_col = NULL) { | ||
rlang::abort(err_unable_to_modify_dag) | ||
} |
Oops, something went wrong.