cugraph.ego_graph#

cugraph.ego_graph(G, n, radius=1, center=True, undirected=None, distance=None)[source]#

Compute the induced subgraph of neighbors centered at node n, within a given radius.

Parameters:
Gcugraph.Graph, networkx.Graph, CuPy or SciPy sparse matrix

Graph or matrix object, which should contain the connectivity information. Edge weights, if present, should be single or double precision floating point values.

ninteger or list, cudf.Series, cudf.DataFrame

A single node as integer or a cudf.DataFrame if nodes are represented with multiple columns. If a cudf.DataFrame is provided, only the first row is taken as the node input.

radius: integer, optional (default=1)

Include all neighbors of distance<=radius from n.

center: bool, optional

Defaults to True. False is not supported

undirected: bool, optional

This parameter is here for NetworkX compatibility and is ignored

distance: key, optional (default=None)

This parameter is here for NetworkX compatibility and is ignored

Returns:
G_egocuGraph.Graph or networkx.Graph

A graph descriptor with a minimum spanning tree or forest. The networkx graph will not have all attributes copied over

Examples

>>> from cugraph.datasets import karate
>>> G = karate.get_graph(download=True)
>>> ego_graph = cugraph.ego_graph(G, 1, radius=2)