cugraph.dask.cores.k_core.k_core#

cugraph.dask.cores.k_core.k_core(input_graph, 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.

Parameters:
input_graphcuGraph.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 or dask_cudf.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.

core_number[‘vertex’]cudf.Series or dask_cudf.Series

Contains the vertex identifiers

core_number[‘values’]cudf.Series or dask_cudf.Series

Contains the core number of vertices

Returns:
resultdask_cudf.DataFrame

GPU distributed data frame containing the K Core of the input graph

ddf[‘src’]: dask_cudf.Series

Contains sources of the K Core

ddf[‘dst’]: dask_cudf.Series

Contains destinations of the K Core

and/or

ddf[‘weights’]: dask_cudf.Series

Contains weights of the K Core

Examples

>>> import cugraph.dask as dcg
>>> import dask_cudf
>>> # ... Init a DASK Cluster
>>> #    see https://docs.rapids.ai/api/cugraph/stable/dask-cugraph.html
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/..
>>> chunksize = dcg.get_chunksize(datasets_path / "karate.csv")
>>> ddf = dask_cudf.read_csv(datasets_path / "karate.csv",
...                          blocksize=chunksize, delimiter=" ",
...                          names=["src", "dst", "value"],
...                          dtype=["int32", "int32", "float32"])
>>> dg = cugraph.Graph(directed=False)
>>> dg.from_dask_cudf_edgelist(ddf, source='src', destination='dst',
...                            edge_attr='value')
>>> KCore_df = dcg.k_core(dg)