all_triplets#

all_triplets(G)[source]#

Returns a generator of all possible sets of 3 nodes in a DiGraph.

Deprecated since version 3.3: all_triplets is deprecated and will be removed in NetworkX version 3.5. Use itertools.combinations instead:

all_triplets = itertools.combinations(G, 3)
Parameters:
Gdigraph

A NetworkX DiGraph

Returns:
tripletsgenerator of 3-tuples

Generator of tuples of 3 nodes

Examples

>>> G = nx.DiGraph([(1, 2), (2, 3), (3, 4)])
>>> list(nx.all_triplets(G))
[(1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]