code: def compute_v_structures(G):
      """Iterate through the graph to compute all v-structures.
  
      V-structures are triples in the directed graph where
      two parent nodes point to the same child and the two parent nodes
      are not adjacent.
  
      Parameters
      ----------
      G : graph
          A networkx DiGraph.
  
      Returns
      -------
      vstructs : iterator of tuples
          The v structures within the graph. Each v structure is a 3-tuple with the
          parent, collider, and other parent.
  
      Examples
      --------
      >>> G = nx.DiGraph()
      >>> G.add_edges_from([(1, 2), (0, 5), (3, 1), (2, 4), (3, 1), (4, 5), (1, 5)])
      >>> sorted(nx.compute_v_structures(G))
      [(0, 5, 1), (0, 5, 4), (1, 5, 4)]
  
      Notes
      -----
      `Wikipedia: Collider in causal graphs <https://en.wikipedia.org/wiki/Collider_(statistics)>`_
      """
      for collider, preds in G.pred.items():
          for common_parents in combinations(preds, r=2):
              # ensure that the colliders are the same
              common_parents = sorted(common_parents)
              yield (common_parents[0], collider, common_parents[1])
  
imports: import heapq
  from collections import deque
  from functools import partial
  from itertools import chain, combinations, product, starmap
  from math import gcd
  import networkx
  from networkx.utils import arbitrary_element, not_implemented_for, pairwise
label_desc: Use image node_id 18 for calling a global function with example usage: compute_v_structures(G) without return types