code: def is_directed_acyclic_graph(G):
      """Returns True if the graph `G` is a directed acyclic graph (DAG) or
      False if not.
  
      Parameters
      ----------
      G : NetworkX graph
  
      Returns
      -------
      bool
          True if `G` is a DAG, False otherwise
  
      Examples
      --------
      Undirected graph::
  
          >>> G = nx.Graph([(1, 2), (2, 3)])
          >>> nx.is_directed_acyclic_graph(G)
          False
  
      Directed graph with cycle::
  
          >>> G = nx.DiGraph([(1, 2), (2, 3), (3, 1)])
          >>> nx.is_directed_acyclic_graph(G)
          False
  
      Directed acyclic graph::
  
          >>> G = nx.DiGraph([(1, 2), (2, 3)])
          >>> nx.is_directed_acyclic_graph(G)
          True
  
      See also
      --------
      topological_sort
      """
      return G.is_directed() and not has_cycle(G)
  
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 4 for calling a global function with example usage: is_directed_acyclic_graph(G) and returns: unknown