def is_directed_acyclic_graph(G):
 if (not G.is_directed()):
  return False
 try:
  consume(topological_sort(G))
  return True
 except nx.NetworkXUnfeasible:
  return False

def is_directed_acyclic_graph ( G ) : if ( not G . is_directed ( ) ) : return False try : consume ( topological_sort ( G ) ) return True except nx . NetworkXUnfeasible : return False
return true if the graph g is a directed acyclic graph or false if not .