Skip to content

Commit

Permalink
fix: fix the incorrect handling of the sample parameter in `sample_…
Browse files Browse the repository at this point in the history
…motifs()` and ensure that the default `sample.size` is integer
  • Loading branch information
szhorvat committed Oct 31, 2024
1 parent a871789 commit b84732e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion R/motifs.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ count_motifs <- function(graph, size = 3, cut.prob = rep(0, size)) {
#' count_motifs(g, 3)
#' sample_motifs(g, 3)
sample_motifs <- function(graph, size = 3, cut.prob = rep(0, size),
sample.size = vcount(graph) / 10, sample = NULL) {
sample.size = ceiling(vcount(graph) / 10), sample = NULL) {
ensure_igraph(graph)
cut.prob <- as.numeric(cut.prob)
if (length(cut.prob) != size) {
Expand All @@ -226,6 +226,10 @@ sample_motifs <- function(graph, size = 3, cut.prob = rep(0, size),
)
}

if (!is.null(sample)) {
sample <- as_igraph_vs(graph, sample) - 1
}

on.exit(.Call(R_igraph_finalizer))
.Call(
R_igraph_motifs_randesu_estimate, graph, as.numeric(size),
Expand Down
2 changes: 1 addition & 1 deletion man/sample_motifs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b84732e

Please sign in to comment.