code: def assign_levels(G, root):
      level = {}
      level[root] = 0
      for v1, v2 in nx.bfs_edges(G, root):
          level[v2] = level[v1] + 1
  
      return level
  
file_path: networkx/networkx/algorithms/isomorphism/tree_isomorphism.py
imports: import networkx
  from networkx.utils.decorators import not_implemented_for
label_desc: Use image node_id 2 for calling a global function with example usage: assign_levels(G, root) and returns: level