Return the subgraph induced on nodes in nbunch.
The induced subgraph of the graph has the nodes in nbunch as its node set and the edges adjacent to those nodes as its edge set.
Parameters: | nbunch : list, iterable
copy : bool, optional (default=True)
|
---|---|
Returns: | G : Graph
|
Notes
If copy=True, nodes and edges are copied using copy.deepcopy.
Examples
>>> G = nx.Graph() # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> G.add_path([0,1,2,3])
>>> H = G.subgraph([0,1,2])
>>> print H.edges()
[(0, 1), (1, 2)]