| motifs | R Documentation |
Graph motifs are small connected induced subgraphs with a well-defined structure. These functions search a graph for various motifs.
motifs(graph, size = 3, cut.prob = NULL, callback = NULL)
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 to 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 |
callback |
Optional callback function to call for each motif found.
The function should accept two arguments: Important limitation: Callback functions must NOT call any igraph
functions (including simple queries like |
motifs() searches a graph for motifs of a given size and returns a
numeric vector containing the number of different motifs. The order of
the motifs is defined by their isomorphism class, see
isomorphism_class().
When callback is NULL, motifs() returns a numeric vector,
the number of occurrences of each motif in the graph. The motifs are ordered
by their isomorphism classes. Note that for unconnected subgraphs, which are
not considered to be motifs, the result will be NA.
When callback is provided, the function returns NULL invisibly and calls
the callback function for each motif found.
motifs_randesu(), motifs_randesu_callback_closure()
isomorphism_class()
Other graph motifs:
count_motifs(),
dyad_census(),
sample_motifs()
g <- sample_pa(100)
motifs(g, 3)
count_motifs(g, 3)
sample_motifs(g, 3)
# Using callback to stop search after finding 5 motifs
count <- 0
motifs(g, 3, callback = function(vids, isoclass) {
count <<- count + 1
count < 5 # stop after 5 motifs
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.