Skip to contents

This function searches for motifs in a graph and calls a user-provided callback function for each motif found.

Usage

motifs_randesu_callback(graph, size = 3, cut_prob = NULL, callback)

Arguments

graph

Graph object, the input graph.

size

The size of the motif, currently sizes 3 and 4 are supported in directed graphs and sizes 3-6 in undirected graphs.

cut_prob

Numeric vector giving the probabilities that the search graph is cut at a certain level. Its length should be the same as the size of the motif (the size argument). If NULL, the default, no cuts are made.

callback

A function to call for each motif found. The function should accept two arguments: vids (integer vector of vertex IDs in the motif, 1-based indexing) and isoclass (the isomorphism class of the motif, 1-based). The function should return TRUE to continue the search or FALSE to stop it.

Value

NULL, invisibly. This function is called for its side effects (calling the callback function for each motif).

motifs_randesu_callback().

Examples

g <- sample_pa(100)
count <- 0
motifs_randesu_callback(g, 3, callback = function(vids, isoclass) {
  count <<- count + 1
  TRUE  # continue search
})
cat("Found", count, "motifs\n")
#> Found 393 motifs