code: def kahn_topological_sort(A, start_nodes):
      """Applies Kahn's algorithm to return a topological sort of the graph. Starts with
      start_nodes. A is adjacency graph. Following pseudo code in Wikipedia.
      """
      ret = []
      edges = deepcopy(A)
      S = (
          deepcopy(start_nodes)
          if hasattr(start_nodes, "__iter__")
          else [start_nodes]
      )
      while len(S) > 0:
          curr_node = S.pop(0)
          ret.append(curr_node)
          curr_nbd = get_nonzero_indices_in_vector(edges[curr_node])
          edges[curr_node] = 0
          for neighbor in curr_nbd:
              if not edges[:, neighbor].sum() > 0:
                  S.append(neighbor)
      has_cycles = False if edges.sum() == 0 else True
      return ret, has_cycles
  
file_path: dragonfly/dragonfly/utils/graph_utils.py
imports: from copy import deepcopy
  import numpy
  from scipy.linalg import eigh
  from .general_utils import get_nonzero_indices_in_vector
label_desc: Use image node_id 15 for calling a global function with example usage: kahn_topological_sort(A, start_nodes) and returns: ret,  has_cycles