Skip to content

Commit 0653197

Browse files
Catch PAG class for igraph, tidygraph, and bnlearn
1 parent 0d7a506 commit 0653197

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

R/as_caugi.R

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ S7::method(
7575
nm <- igraph::V(x)$name
7676
if (is.null(nm)) nm <- paste0("V", seq_len(igraph::vcount(x)))
7777

78+
if (class == "PAG") {
79+
stop("PAG class is not supported for igraph objects.", call. = FALSE)
80+
}
7881
if (n_edges == 0L) {
7982
return(caugi_graph(
8083
from = character(),
@@ -484,6 +487,9 @@ S7::method(
484487
collapse_to = "---",
485488
...) {
486489
class <- match.arg(class)
490+
if (class == "PAG") {
491+
stop("PAG class is not supported for tidygraph objects.", call. = FALSE)
492+
}
487493
as_caugi(
488494
tidygraph::as.igraph(x),
489495
class = class,
@@ -619,6 +625,11 @@ S7::method(
619625
collapse_to = "---",
620626
...) {
621627
class <- match.arg(class)
628+
629+
if (class == "PAG") {
630+
stop("PAG class is not supported for bnlearn objects.", call. = FALSE)
631+
}
632+
622633
nm <- bnlearn::nodes(x)
623634
ar <- bnlearn::arcs(x)
624635

@@ -631,7 +642,7 @@ S7::method(
631642
nodes = nm,
632643
simple = isTRUE(simple),
633644
build = isTRUE(build),
634-
class = if (class == "PAG") "Unknown" else class
645+
class = class
635646
))
636647
}
637648

@@ -655,11 +666,6 @@ S7::method(
655666
edge <- ifelse(has_rev & keep, collapse_to, edge)[keep]
656667
}
657668

658-
# todo:
659-
### NEEDS TO BE FIXED ONCE PAG IS SUPPORTED IN CAUGI ###
660-
class <- if (class == "PAG") "Unknown" else class
661-
### NEEDS TO BE FIXED ONCE PAG IS SUPPORTED IN CAUGI ###
662-
663669
caugi_graph(
664670
from = from,
665671
edge = edge,

0 commit comments

Comments
 (0)