cugraph.core_number#

cugraph.core_number(G, degree_type='bidirectional')[source]#

Compute the core numbers for the nodes of the graph G. A k-core of a graph is a maximal subgraph that contains nodes of degree k or more. A node has a core number of k if it belongs to a k-core but not to k+1-core. This call does not support a graph with self-loops and parallel edges.

Parameters:
GcuGraph.Graph or networkx.Graph

The current implementation only supports undirected graphs. The graph can contain edge weights, but they don’t participate in the calculation of the core numbers.

Deprecated since version 24.12: Accepting a networkx.Graph is deprecated and will be removed in a future version. For networkx.Graph use networkx directly with the nx-cugraph backend. See: https://rapids.ai/nx-cugraph/

degree_type: str, (default=”bidirectional”)

This option is currently ignored. This option may eventually determine if the core number computation should be based on input, output, or both directed edges, with valid values being “incoming”, “outgoing”, and “bidirectional” respectively.

Returns:
dfcudf.DataFrame or python dictionary (in NetworkX input)

GPU data frame containing two cudf.Series of size V: the vertex identifiers and the corresponding core number values.

df[‘vertex’]cudf.Series

Contains the vertex identifiers

df[‘core_number’]cudf.Series

Contains the core number of vertices

Examples

>>> from cugraph.datasets import karate
>>> G = karate.get_graph(download=True)
>>> df = cugraph.core_number(G)
>>> df.head()
   vertex  core_number
0      33            4
1       0            4
2      32            4
3       2            4
4       1            4