code: def remove_isolated_nodes(G):
      
  
      isolated_nodes = [node for node, degree in dict(G.degree()).items() if degree < 1]
      G.remove_nodes_from(isolated_nodes)
      log('Removed {:,} isolated nodes'.format(len(isolated_nodes)))
      return G
docs: Remove from a graph all the nodes that have no incident edges (ie, node
      degree = 0).
  
      Parameters
      ----------
      G : networkx multidigraph
          the graph from which to remove nodes
  
      Returns
      -------
      networkx multidigraph