def remove_isolated(G):
  """
  Remove nodes with degree 0 from G
  """
  H = G.copy()
  node_to_degree = H.degree()
  for node, degree in node_to_degree.items():
    if degree == 0:
      H.remove_node(node)
  return H