MCPcopy Create free account
hub / github.com/alibaba/GraphScope / induced_subgraph

Function induced_subgraph

python/graphscope/nx/classes/function.py:99–123  ·  view source on GitHub ↗

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

(G, nbunch)

Source from the content-addressed store, hash-verified

97
98
99def induced_subgraph(G, nbunch):
100 """Returns a independent deep copy subgraph induced on nbunch.
101
102 The induced subgraph of a graph on a set of nodes N is the
103 graph with nodes N and edges from G which have both ends in N.
104
105 Parameters
106 ----------
107 G : NetworkX Graph
108 nbunch : node, container of nodes or None (for all nodes)
109
110 Returns
111 -------
112 subgraph : SubGraph
113 A independent deep copy of the subgraph in `G` induced by the nodes.
114
115 Examples
116 --------
117 >>> G = nx.path_graph(4) # or DiGraph, MultiGraph, MultiDiGraph, etc
118 >>> H = G.subgraph([0, 1, 2])
119 >>> list(H.edges)
120 [(0, 1), (1, 2)]
121 """
122 induced_nodes = G.nbunch_iter(nbunch)
123 return G.subgraph(induced_nodes)
124
125
126def edge_subgraph(G, edges):

Callers

nothing calls this directly

Calls 2

nbunch_iterMethod · 0.80
subgraphMethod · 0.45

Tested by

no test coverage detected