# Counting motifs

Warning

The enumeration of motifs can take a little while. It depends on the number of nodes in the networks, and in the number of nodes in the motif. It may be wise, in case you want to count several motifs on a single network, to use Julia's parallel computing abilities to speed things up.

## How it works

Internally, the code to count motifs is *Not Elegant*™. Every motif is represented by its adjacency matrix, as a `DeterministicNetwork`

object. Then *all* possible induced sub-graphs with the same number of nodes (at either level if this is a `Bipartite`

) are extracted, and matched against all *unique* possible permutations of the motif. If there is a match, then this induced subgraph is an instance of this motif.

#
** EcologicalNetwork.motif** —

*Function*.

**Count motifs**

motif(N::EcoNetwork, m::DeterministicNetwork)

In a network `N`

, counts the number of time a motif `m`

appears. In the case of a probabilistic network, `N`

is the expected number of motifs. In the case of a quantitative network, `N`

is the number of times the motif appears in the unweighted network.

Note that because self-edges (*a.k.a.* loops, or cannibalism) are *not* counted in the motifs (the adjacency matrix is treated as if it had all diagonal elements set to 0).

## Caveats

The motifs are counted in a way that ignore self-links. This should not be an issue most of the time, and was also the ways this was done in most publications counting motifs in ecological networks.

## Usual motifs

#
** EcologicalNetwork.unipartitemotifs** —

*Function*.

**Unipartite motifs**

unipartitemotifs()

The names of the motifs come from Stouffer et al. (2007) – especially Fig. 1, available online at http://rspb.royalsocietypublishing.org/content/274/1621/1931.figures-only