networkx.classes.function.subgraph

subgraph(G, nbunch)[source]

Returns the subgraph induced on nodes in nbunch.

Parameters
Ggraph

A NetworkX graph

nbunchlist, iterable

A container of nodes that will be iterated through once (thus it should be an iterator or be iterable). Each element of the container should be a valid node type: any hashable type except None. If nbunch is None, return all edges data in the graph. Nodes in nbunch that are not in the graph will be (quietly) ignored.

Notes

subgraph(G) calls G.subgraph()