title: Loop though connected components in networkx and extract components that contain certain nodes
body: <p>I have a very large undirected network loaded into a NetworkX <code>graph()</code> that is composed of many disconnected components.  I also have a set of nodes of interest loaded into a set.  I would like to look through all of the extract all of the components have contain at least one of the nodes of interest.  </p>
  
  <pre><code># create empty graph
  g = nx.Graph()
  
  # add edges to the graph
  g.add_edges_from([['a','b'],['a','c'],['b','c'],['d','e'],['e','f'],['d','f'],['g','h'],['g','i'],['h','i']])
  
  # load nodes of interest into a set
  interest_nodes = set(['a', 'b', 'f'])
  
  # number of connected components
  nx.number_connected_components(g)
  
  # loop through each connected component and add all of the edges for that component to a list if a node in that component is found in the interest_nodes
  interest_edges = []
  for i in nx.connected_component_subgraph(g):
      for u in i.edges():
          if u in interest_nodes:
              interest_edges.append(u)
  </code></pre>
  
  <p>However, I get back an empty list.  </p>
  
  <p>Ideally, I would want back a list with all of the edges in any connected component that contains at least one of the nodes in the <code>interest_nodes</code> set.  What I should get back below, but instead I don't get back anything. </p>
  
  <pre><code>interest_edges = [('a', 'c'),
                    ('a', 'b'),
                    ('c', 'b'),
                    ('e', 'd'),
                    ('e', 'f'),
                    ('d', 'f')]
  </code></pre>