graphscope.nx.classes.function.induced_subgraph

graphscope.nx.classes.function.induced_subgraph(G, nbunch)[source]

Returns a independent deep copy subgraph induced on nbunch.

The induced subgraph of a graph on a set of nodes N is the graph with nodes N and edges from G which have both ends in N.

Parameters:
  • G (NetworkX Graph) –

  • nbunch (node, container of nodes or None (for all nodes)) –

Returns:

subgraph – A independent deep copy of the subgraph in G induced by the nodes.

Return type:

SubGraph

Examples

>>> G = nx.path_graph(4)  # or DiGraph, MultiGraph, MultiDiGraph, etc
>>> H = G.subgraph([0, 1, 2])
>>> list(H.edges)
[(0, 1), (1, 2)]