title: Creating a random edge to a neighbor that excludes one particular node in Networkx
body: <p>I'm trying to write a function that will remove 2 random edges from a specific node in my graph except an edge with another particular node. I'm using the Python Networkx package. Here's my code:</p>
  
  <pre><code>close = nx.closeness_centrality(self.combined_network) #This calculates closeness
  self.most_central_node = max(close.items(), key=itemgetter(1))[0] identifies the maximum centrality
  self.combined_network.add_edge(self.most_central_node, 'bad_apple_Bad_apple') adds an edge from the most central node to a specific node
  </code></pre>
  
  <p>what I'd like to do next is ask self.most_central_node to break 2 edges (randomly) but not to break the one I just created with 'bad_apple_Bad_apple'. I've tried first selecting most_central_node's neighbors using:</p>
  
  <pre><code>Neighb = (B.neighbors(most_central_node))
  </code></pre>
  
  <p>That worked, but it returns a list. Now I'm trying to build that list  without "bad_apple_Bad_apple"</p>
  
  <p>I tried:</p>
  
  <pre><code>n2 = B.node['bad_apple_0']
  n3 = (item for item in Neighb if item not in n2)
  </code></pre>
  
  <p>That doesn't work I think.  When I print n3 in the console I get:<br>
  <code>&lt;generator object &lt;genexpr&gt; at 0x00000000203845E8&gt;</code></p>
  
  <p>What am I doing wrong? I will then need to select 2 of those at random to ask most_central_node to break its edges with them. Can someone point the way on that too?</p>