Skip to content

Commit

Permalink
is_tree: separate VERTEX_ROOT type
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonov548 committed Oct 27, 2023
1 parent f772ee3 commit cb7ceda
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
9 changes: 4 additions & 5 deletions R/aaa-auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions tools/stimulus/functions-R.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
#######################################
Expand Down
13 changes: 13 additions & 0 deletions tools/stimulus/types-RR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit cb7ceda

Please sign in to comment.