code: def all_triads(G):
      """A generator of all possible triads in G.
  
      Parameters
      ----------
      G : digraph
         A NetworkX DiGraph
  
      Returns
      -------
      all_triads : generator 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)]
  
      """
      triplets = combinations(G.nodes(), 3)
      for triplet in triplets:
          yield G.subgraph(triplet).copy()
  
file_path: networkx/networkx/algorithms/triads.py
imports: from collections import defaultdict
  from itertools import combinations, permutations
  import networkx
  from networkx.utils import not_implemented_for, py_random_state
label_desc: Use image node_id 5 for calling a global function with example usage: all_triads(G) without return types