to_motifs() returns a named list of small networks representing the motifs (subgraphs, or isomorphism classes) that a network of a given type could contain. Unlike most other to_*() functions, it does not modify and return the network passed to it, but instead uses that network only to work out which motifs are relevant, returning the whole reference set of motifs as a list. It is meant to help interpret the results of motif counts, such as netrics::net_x_triads().

Either .data or n (or both) can be given. When a network is passed to .data, the direction, signedness, and mode(s) of the motifs are inferred from it, as is the number of nodes n unless n is also given explicitly. Passing n alongside a network lets you choose, say, the dyadic, triadic, or tetradic motifs of that kind of network. When only n is given (e.g. to_motifs(n = 3), or simply to_motifs(3)), the directed/signed arguments are respected instead, which is handy for teaching or illustration.

For one-mode networks, motifs are implemented undirected for n = 2 to n = 4, directed for n = 2 and n = 3, signed undirected for n = 2 and n = 3, and signed directed for n = 2. Where more nodes are requested (or inferred from a larger network) than are implemented, the largest available motif set is returned.

For two-mode networks, the seven bipartite motifs up to four nodes are returned, labelled by their bmotif dictionary IDs (Simmons et al. 2019): motif 1 (a single tie), motifs 2-3 (three nodes), and motifs 4-7 (four nodes, namely the two stars, the 2x2 path, and the 2x2 four-cycle).

to_motifs(.data = NULL, n = NULL, directed = FALSE, signed = FALSE)

create_motifs(.data = NULL, n = NULL, directed = FALSE, signed = FALSE)

Arguments

.data

An optional {manynet}-consistent network (matrix, edgelist, igraph, tidygraph, network, or stocnet object), from which the direction, signedness, mode(s), and (unless n is given) number of nodes of the motifs are inferred. Either .data or n must be provided.

n

An optional number of nodes the motifs should contain, as a single integer (one-mode) or a length-two integer vector (two-mode). If omitted, it is inferred from .data; if given alongside .data it overrides the network's own size (e.g. to list the triadic motifs of a larger network). Either .data or n must be provided.

directed

Logical whether the motifs should be directed. By default FALSE. Ignored (and inferred instead) when .data is a network.

signed

Logical whether the motifs should be signed. By default FALSE. Ignored (and inferred instead) when .data is a network. Currently available for undirected n = 2 and n = 3, and directed n = 2 (see the "Signed directed dyads" section).

Value

A named list of {manynet}-compatible networks, one per motif.

Signed directed dyads

The six signed directed dyads (n = 2, directed, signed) are the Holland-Leinhardt dyad census (Null, Asymmetric, Mutual) refined by the sign of each arc. They correspond to the dyadic reciprocity motifs of Gallo et al. (2025) as follows:

to_motifs() labelStructureGallo et al. (2025)
Nullno ties(empty dyad)
Asymmetric+one positive arc\(L^{+}_{\rightarrow}\) (single positive)
Asymmetric-one negative arc\(L^{-}_{\rightarrow}\) (single negative)
Mutual++reciprocated, both positive\(L^{+}_{\leftrightarrow}\) (reciprocated positive)
Mutual--reciprocated, both negative\(L^{-}_{\leftrightarrow}\) (reciprocated negative)
Mutual+-reciprocated, discordant signs\(L^{\pm}_{\leftrightarrow}\) (reciprocated mixed)

References

Simmons, Benno I., Michelle J.M. Sweering, Maybritt Schillinger, Lynn V. Dicks, William J. Sutherland, and Riccardo Di Clemente. 2019. "bmotif: A package for motif analyses of bipartite networks." Methods in Ecology and Evolution 10(5): 695-701. doi:10.1111/2041-210X.13149

Gallo, Anna, Fabio Saracco, Renaud Lambiotte, Diego Garlaschelli, and Tiziano Squartini. 2025. "Patterns of link reciprocity in directed, signed networks." Physical Review E 111(2): 024312. doi:10.1103/PhysRevE.111.024312

Examples

  to_motifs(3)
#> $Empty
#> 
#> ── # Empty network ─────────────────────────────────────────────────────────────
#> # A labelled, undirected network of 3 nodes and 0 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
#> 
#> 
#> $Edge
#> # A labelled, undirected network of 3 nodes and 1 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 
#> 
#> $Path
#> # A labelled, undirected network of 3 nodes and 2 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 2 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 
#> 
#> $Triangle
#> # A labelled, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 3     1     3
#> 
#> 
  to_motifs(n = 2, directed = TRUE)
#> $Null
#> ── # Empty network ─────────────────────────────────────────────────────────────
#> # A labelled, directed network of 2 nodes and 0 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
#> 
#> 
#> $Asymmetric
#> # A labelled, directed network of 2 nodes and 1 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 
#> 
#> $Mutual
#> # A labelled, directed network of 2 nodes and 2 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 2 × 2
#>    from    to
#>   <int> <int>
#> 1     2     1
#> 2     1     2
#> 
#> 
  to_motifs(create_ring(8), n = 3)
#> $Empty
#> ── # Empty network ─────────────────────────────────────────────────────────────
#> # A labelled, undirected network of 3 nodes and 0 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
#> 
#> 
#> $Edge
#> # A labelled, undirected network of 3 nodes and 1 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 1 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 
#> 
#> $Path
#> # A labelled, undirected network of 3 nodes and 2 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 2 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 
#> 
#> $Triangle
#> # A labelled, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 2
#>    from    to
#>   <int> <int>
#> 1     1     2
#> 2     2     3
#> 3     1     3
#> 
#> 
  to_motifs(3, signed = TRUE)
#> $Empty
#> ── # Empty network ─────────────────────────────────────────────────────────────
#> # A labelled, undirected network of 3 nodes and 0 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
#> 
#> 
#> $`+`
#> # A labelled, signed, undirected network of 3 nodes and 1 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 1 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 
#> 
#> $`-`
#> # A labelled, signed, undirected network of 3 nodes and 1 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 1 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2    -1
#> 
#> 
#> $`++`
#> # A labelled, signed, undirected network of 3 nodes and 2 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 2     2     3     1
#> 
#> 
#> $`+-`
#> # A labelled, signed, undirected network of 3 nodes and 2 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 2     2     3    -1
#> 
#> 
#> $`--`
#> # A labelled, signed, undirected network of 3 nodes and 2 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2    -1
#> 2     2     3    -1
#> 
#> 
#> $`+++`
#> # A labelled, signed, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 2     2     3     1
#> 3     1     3     1
#> 
#> 
#> $`++-`
#> # A labelled, signed, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 2     2     3     1
#> 3     1     3    -1
#> 
#> 
#> $`+--`
#> # A labelled, signed, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 2     2     3    -1
#> 3     1     3    -1
#> 
#> 
#> $`---`
#> # A labelled, signed, undirected network of 3 nodes and 3 ties
#> 
#> ── Nodes 
#> # A tibble: 3 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 3 C    
#> 
#> ── Ties 
#> # A tibble: 3 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2    -1
#> 2     2     3    -1
#> 3     1     3    -1
#> 
#> 
  to_motifs(2, directed = TRUE, signed = TRUE)
#> $Null
#> ── # Empty network ─────────────────────────────────────────────────────────────
#> # A labelled, directed network of 2 nodes and 0 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 0 × 2
#> # ℹ 2 variables: from <int>, to <int>
#> 
#> 
#> $`Asymmetric+`
#> # A labelled, signed, directed network of 2 nodes and 1 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 1 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2     1
#> 
#> 
#> $`Asymmetric-`
#> # A labelled, signed, directed network of 2 nodes and 1 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 1 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     1     2    -1
#> 
#> 
#> $`Mutual++`
#> # A labelled, signed, directed network of 2 nodes and 2 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     2     1     1
#> 2     1     2     1
#> 
#> 
#> $`Mutual--`
#> # A labelled, signed, directed network of 2 nodes and 2 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     2     1    -1
#> 2     1     2    -1
#> 
#> 
#> $`Mutual+-`
#> # A labelled, signed, directed network of 2 nodes and 2 arcs
#> 
#> ── Nodes 
#> # A tibble: 2 × 1
#>   name 
#>   <chr>
#> 1 A    
#> 2 B    
#> 
#> ── Ties 
#> # A tibble: 2 × 3
#>    from    to  sign
#>   <int> <int> <dbl>
#> 1     2     1     1
#> 2     1     2    -1
#> 
#>