triads_by_type#

triads_by_type(G)[source]#

Returns a list of all triads for each triad type in a directed graph. There are exactly 16 different types of triads possible. Suppose 1, 2, 3 are three nodes, they will be classified as a particular triad type if their connections are as follows:

  • 003: 1, 2, 3

  • 012: 1 -> 2, 3

  • 102: 1 <-> 2, 3

  • 021D: 1 <- 2 -> 3

  • 021U: 1 -> 2 <- 3

  • 021C: 1 -> 2 -> 3

  • 111D: 1 <-> 2 <- 3

  • 111U: 1 <-> 2 -> 3

  • 030T: 1 -> 2 -> 3, 1 -> 3

  • 030C: 1 <- 2 <- 3, 1 -> 3

  • 201: 1 <-> 2 <-> 3

  • 120D: 1 <- 2 -> 3, 1 <-> 3

  • 120U: 1 -> 2 <- 3, 1 <-> 3

  • 120C: 1 -> 2 -> 3, 1 <-> 3

  • 210: 1 -> 2 <-> 3, 1 <-> 3

  • 300: 1 <-> 2 <-> 3, 1 <-> 3

Refer to the example gallery for visual examples of the triad types.

Parameters:
Gdigraph

A NetworkX DiGraph

Returns:
tri_by_typedict

Dictionary with triad types as keys and lists of triads as values.

References

[1]

Snijders, T. (2012). “Transitivity and triads.” University of Oxford. https://web.archive.org/web/20170830032057/http://www.stats.ox.ac.uk/~snijders/Trans_Triads_ha.pdf

Examples

>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 3), (3, 1), (5, 6), (5, 4), (6, 7)])
>>> dict = nx.triads_by_type(G)
>>> dict["120C"][0].edges()
OutEdgeView([(1, 2), (1, 3), (2, 3), (3, 1)])
>>> dict["012"][0].edges()
OutEdgeView([(1, 2)])