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

Compute the k-core of the graph G based on the out degree of its nodes. A k-core of a graph is a maximal subgraph that contains nodes of degree k or more. This call does not support a graph with self-loops and parallel edges.

GcuGraph.Graph or networkx.Graph

cuGraph graph descriptor with connectivity information. The graph should contain undirected edges where undirected edges are represented as directed edges in both directions. While this graph can contain edge weights, they don’t participate in the calculation of the k-core. The current implementation only supports undirected graphs.

kint, optional (default=None)

Order of the core. This value must not be negative. If set to None, the main core is returned.

degree_type: str, (default=”bidirectional”)

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

core_numbercudf.DataFrame, optional (default=None)

Precomputed core number of the nodes of the graph G containing two cudf.Series of size V: the vertex identifiers and the corresponding core number values. If set to None, the core numbers of the nodes are calculated internally.


Contains the vertex identifiers


Contains the core number of vertices


K Core of the input graph


>>> from cugraph.datasets import karate
>>> G = karate.get_graph(download=True)
>>> KCoreGraph = cugraph.k_core(G)