From cb7ceda00cb6c0f21bdf475ee10d2125ecdaeff2 Mon Sep 17 00:00:00 2001 From: Antonov548 Date: Fri, 27 Oct 2023 14:17:57 +0200 Subject: [PATCH] is_tree: separate `VERTEX_ROOT` type --- R/aaa-auto.R | 9 ++++----- tools/stimulus/functions-R.yaml | 4 ++++ tools/stimulus/types-RR.yaml | 13 +++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/R/aaa-auto.R b/R/aaa-auto.R index 2a2aad6847..b43d7d7c03 100644 --- a/R/aaa-auto.R +++ b/R/aaa-auto.R @@ -3791,13 +3791,12 @@ is_tree_impl <- function(graph, mode=c("out", "in", "all", "total"), details=FAL on.exit( .Call(R_igraph_finalizer) ) # Function call res <- .Call(R_igraph_is_tree, graph, mode) - if (!details) { - res <- res$res -} else if (vcount(graph) == 0) { - # FIXME: Better handled in rinterface_extra.c, or via a dedicated type? - } else if (igraph_opt("return.vs.es")) { + if (igraph_opt("return.vs.es") && vcount(graph) != 0) { res$root <- create_vs(graph, res$root) } + if (!details) { + res <- res$res + } res } diff --git a/tools/stimulus/functions-R.yaml b/tools/stimulus/functions-R.yaml index d3386d0ef4..63d06824fc 100644 --- a/tools/stimulus/functions-R.yaml +++ b/tools/stimulus/functions-R.yaml @@ -1125,6 +1125,10 @@ igraph_get_stochastic_sparsemat: igraph_hrg_dendrogram: PARAMS: OUT GRAPH graph, HRG hrg +igraph_is_tree: + PARAMS: GRAPH graph, PRIMARY OUT BOOLEAN res, OPTIONAL OUT VERTEX_ROOT root, NEIMODE mode=OUT + DEPS: root ON graph + ####################################### # Coloring ####################################### diff --git a/tools/stimulus/types-RR.yaml b/tools/stimulus/types-RR.yaml index c8bd743886..c4abfd92a3 100644 --- a/tools/stimulus/types-RR.yaml +++ b/tools/stimulus/types-RR.yaml @@ -130,6 +130,19 @@ VERTEX: %I% <- create_vs(%I1%, %I%) } +VERTEX_ROOT: + CALL: '%I%-1' + INCONV: |- + %I% <- as_igraph_vs(%I1%, %I%) + if (length(%I%) == 0) { + stop("No vertex was specified") + } + OUTCONV: + OUT: |- + if (igraph_opt("return.vs.es") && vcount(%I1%) != 0) { + %I% <- create_vs(%I1%, %I%) + } + VERTEX_SELECTOR: CALL: '%I%-1' DEFAULT: