title: NetworkX DiGraph create subgraph (DiGraph) by node
body: <p>I would like to get a subgraph (red area) by node:
  The subgraph is composed of all the nodes reachable from the input node.</p>
  
  <blockquote>
    <p>like G.subgraph(3) returns a new DiGraph from the red area.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/P80AQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/P80AQ.png" alt="enter image description here"></a></p>
  
  <p>For example I create a DiGraph as this:</p>
  
  <pre><code>import networkx as nx
  G = nx.DiGraph()
  
  G.add_path([1,2,3,4])
  G.add_path([3,'a','b'])
  
  A = nx.to_agraph(G)
  A.layout()
  A.draw('graph.png')
  </code></pre>
  
  <p>I looked into <a href="https://networkx.github.io/documentation/latest/reference/generated/networkx.Graph.subgraph.html" rel="noreferrer">https://networkx.github.io/documentation/latest/reference/generated/networkx.Graph.subgraph.html</a> and converting it to unidirectional. I tested out_egdes, strong/weak_connected_component, but its never worked.
  I also looked <a href="https://stackoverflow.com/questions/18643789/how-to-find-subgraphs-in-a-directed-graph-without-converting-to-undirected-graph">How to find subgraphs in a directed graph without converting to undirected graph?</a> and <a href="https://stackoverflow.com/questions/13914920/networkx-extract-the-smallest-connected-subgraph">Networkx: extract the connected component containing a given node (directed graph)</a>. </p>
  
  <p>I know that Subgraph does not work in DiGraph.</p>
  
  <p>Can someone please show me how to do this ? Would be nice if the resulting Graph is also a DiGraph</p>