title: Removing nodes from a nx graph if and only if the graph remains connected?
body: <p>I'm trying to remove nodes from an existing nx graph G if and only if the graph remains connected. What is the most efficient way to do this?</p>
  <p>My attempt for removing node 5 for example is:</p>
  <pre><code>node = 5
  
  # make temporary copy
  T = G.copy()
  
  # remove node from copy
  T.remove_node(node)
  
  # replace G with T if the graph is connected
  if nx.is_connected(T):
      G = T
  </code></pre>
  <p>I'm just hesitant about creating copies to do this since I'm iteratively removing nodes from a large graph. Is there a better way to do this?</p>