all_triads#

all_triads(G)[source]#

A generator of all possible triads in G.

Parameters:
Gdigraph

A NetworkX DiGraph

Returns:
all_triadsgenerator of DiGraphs

Generator of triads (order-3 DiGraphs)

Examples

>>> G = nx.DiGraph([(1, 2), (2, 3), (3, 1), (3, 4), (4, 1), (4, 2)])
>>> for triad in nx.all_triads(G):
...     print(triad.edges)
[(1, 2), (2, 3), (3, 1)]
[(1, 2), (4, 1), (4, 2)]
[(3, 1), (3, 4), (4, 1)]
[(2, 3), (3, 4), (4, 2)]