title: Networkx: extract the connected component containing a given node (directed graph)
body: <p>I am trying to extract from a big graph the sub-graph of all connected nodes containing a specific node.</p>
  
  <p>Is there a solution in the Networkx library?</p>
  
  <p>[EDIT]<br>
  My graph is a DiGraph</p>
  
  <p>[EDIT]<br>
  Rephrased simply:<br>
  I want the part of my graph that contain my specific node N_i and and all the nodes that are connected directly or indirectly (passing by other nodes) using any incoming or outcoming edges.<br>
  Example:</p>
  
  <pre><code>&gt;&gt;&gt; g = nx.DiGraph()
  &gt;&gt;&gt; g.add_path(['A','B','C',])
  &gt;&gt;&gt; g.add_path(['X','Y','Z',])
  &gt;&gt;&gt; g.edges()
  [('A', 'B'), ('B', 'C'), ('Y', 'Z'), ('X', 'Y')]
  </code></pre>
  
  <p>My desired result would be:</p>
  
  <pre><code>&gt;&gt;&gt; g2 = getSubGraph(g, 'B')
  &gt;&gt;&gt; g2.nodes()
  ['A', 'B', 'C']
  &gt;&gt;&gt; g2.edges()
  [('A', 'B'), ('B', 'C')]
  </code></pre>