triad_census

Contents

triad_census#

graph_tool.clustering.triad_census(g)[git][source]#

Return the triad census of the graph.

Parameters:
gGraph

Graph to be used.

Returns:
censusdict

The number of triads of every type, keyed by the type names in the notation of Holland and Leinhardt ("003", "012", "102", "021D", "021U", "021C", "111D", "111U", "030T", "030C", "201", "120D", "120U", "120C", "210", "300").

See also

dyad_census

Dyad census

motifs

Motif counting

motif_significance

Significance profile of motifs

Notes

The triad census [holland-method-1976] counts the subgraphs induced by all \(\binom{V}{3}\) triples of vertices, according to their 16 isomorphism classes as directed graphs. The type name gives the number of mutual, asymmetric, and null dyads of the triad, followed by a letter that distinguishes the classes with the same numbers (D for down, U for up, C for cyclic, and T for transitive). For undirected graphs, every edge is a mutual dyad, so that only the types "003", "102", "201", and "300" occur. Parallel edges and self-loops are ignored.

The census is computed with the algorithm of Batagelj and Mrvar [batagelj-subquadratic-2001], which visits only the triads with at least one edge, in time \(O(E k_{\max})\), in parallel over the vertices. Connected triads are also counted by motifs().

Parallel implementation.

If enabled during compilation, this algorithm will run in parallel using OpenMP. See the parallel algorithms section for information about how to control several aspects of parallelization.

References

[holland-method-1976]

Paul W. Holland and Samuel Leinhardt, “Local structure in social networks”, Sociological Methodology 7, 1-45 (1976), DOI: 10.2307/270703 [sci-hub, @tor]

[batagelj-subquadratic-2001]

Vladimir Batagelj and Andrej Mrvar, “A subquadratic triad census algorithm for large sparse networks with small maximum degree”, Social Networks 23, 237-243 (2001), DOI: 10.1016/S0378-8733(01)00035-1 [sci-hub, @tor]

Examples

>>> g = gt.collection.data["celegansneural"]
>>> census = gt.triad_census(g)
>>> print(census["030T"], census["030C"])
1972 72