code: def reroot_graph(G: nx.DiGraph, node: str) -> nx.DiGraph:
      
      G = G.copy()
      for n, successors in list(nx.bfs_successors(G, source=node)):
          for s in successors:
              G.add_edge(s, n, **G.edges[n, s])
              G.remove_edge(n, s)
      return G
docs: Return a copy of the graph rooted at the given node