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

Method subgraph

python/graphscope/nx/classes/graph.py:1784–1822  ·  view source on GitHub ↗

Returns a independent deep copy subgraph induced on `nodes`. The induced subgraph of the graph contains the nodes in `nodes` and the edges between those nodes. Parameters ---------- nodes : list, iterable A container of nodes which will be iterat

(self, nodes)

Source from the content-addressed store, hash-verified

1782
1783 @clear_mutation_cache
1784 def subgraph(self, nodes):
1785 """Returns a independent deep copy subgraph induced on `nodes`.
1786
1787 The induced subgraph of the graph contains the nodes in `nodes`
1788 and the edges between those nodes.
1789
1790 Parameters
1791 ----------
1792 nodes : list, iterable
1793 A container of nodes which will be iterated through once.
1794
1795 Returns
1796 -------
1797 G : Graph
1798 A subgraph of the graph.
1799
1800 Notes
1801 -----
1802 Unlike NetowrkX return a view, here return a independent deep copy subgraph.
1803
1804 Examples
1805 --------
1806 >>> G = nx.path_graph(4) # or DiGraph
1807 >>> H = G.subgraph([0, 1, 2])
1808 >>> list(H.edges)
1809 [(0, 1), (1, 2)]
1810 """
1811 self._convert_arrow_to_dynamic()
1812
1813 induced_nodes = json.dumps(list(nodes))
1814 g = self.__class__(create_empty_in_engine=False)
1815 g.graph.update(self.graph)
1816 op = dag_utils.create_subgraph(self, nodes=induced_nodes)
1817 graph_def = op.eval(leaf=False)
1818 g._key = graph_def.key
1819 g._session = self._session
1820 g._op = op
1821 g.cache.warmup()
1822 return g
1823
1824 @clear_mutation_cache
1825 def edge_subgraph(self, edges):

Callers 15

test_demo_on_hdfsFunction · 0.45
test_demo_distributeFunction · 0.45
test_demo_with_lazy_modeFunction · 0.45
test_helm_installationFunction · 0.45
to_numpy_arrayFunction · 0.45
to_scipy_sparse_arrayFunction · 0.45

Calls 4

updateMethod · 0.45
evalMethod · 0.45
warmupMethod · 0.45