code: def has_cycle(G):
      """Decides whether the directed graph has a cycle."""
      try:
          # Feed the entire iterator into a zero-length deque.
          deque(topological_sort(G), maxlen=0)
      except nx.NetworkXUnfeasible:
          return True
      else:
          return False
  
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 3 for calling a global function with example usage: has_cycle(G) and returns: False, True