title: Obtain the edges removed by using k-core in Networkx
body: <p>I'm using Networkx's k-core to remove nodes of degree &lt; 2.</p>
  <pre><code>n=20
  G = nx.gnm_random_graph(n=20, m=30, seed=1)
  nx.draw(G, with_labels=True)
  plt.show()
  
  retain_node_ids = [1, 8]
  G.add_edges_from([(u, v) for u in retain_node_ids for v in (n, n+1)])
  pos = nx.spring_layout(G)
  
  G = nx.k_core(G, k=2)
  
  nx.draw(G, with_labels=True, pos=pos)
  plt.show()
  </code></pre>
  <p>k-core returns the subgraph. But I would also want to obtain the list of nodes and edges removed while using k-core.</p>
  <p>Any suggestions will be highly useful.</p>