Skip to content

Commit 234939c

Browse files
Allow for construction of caugi_graph using a cg_state
1 parent 0a6a8d7 commit 234939c

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

R/caugi_graph.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#' nodes are provided, the graph will not be built and the pointer will be
3939
#' `NULL`.
4040
#' @param class Character; one of `"UNKNOWN"`, `"DAG"`, or `"PDAG"`.
41+
#' @param state For internal use. Build a graph by supplying a pre-constructed
42+
#' state environment.
4143
#'
4244
#' @returns A [`caugi_graph`] S7 object containing the nodes, edges, and a
4345
#' pointer to the underlying Rust graph structure.
@@ -190,7 +192,14 @@ caugi_graph <- S7::new_class(
190192
from = NULL, edge = NULL, to = NULL, nodes = NULL,
191193
simple = TRUE,
192194
build = TRUE,
193-
class = c("UNKNOWN", "DAG", "PDAG")) {
195+
class = c("UNKNOWN", "DAG", "PDAG"),
196+
state = NULL) {
197+
if (!is.null(state)) {
198+
return(S7::new_object(
199+
caugi_graph,
200+
`.state` = state
201+
))
202+
}
194203
class <- toupper(class)
195204
class <- match.arg(class)
196205

man/caugi_graph.Rd

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)