Skip to main content

Core Number

SQL function: cugraph_core_number

Official cuGraph reference: C API

Assign each vertex the largest k for which it belongs to a k-core, where every vertex has degree at least k within that subgraph.

Quickstart

The call below supplies edges from registered relation target_edges with canonical src and dst columns and may include weight. Substitute your own registered relations.

SELECT * FROM cugraph_core_number(edges => (SELECT src, dst FROM target_edges));

Inputs

Every relation is a named parenthesized SELECT subquery. The required edges role uses canonical src and dst columns; every role, its canonical columns, and their accepted Arrow types are listed under Relation arguments. Metadata validation resolves registered tables named in its JSON request.

Endpoint columns accept numeric Int32, Int64 vertex IDs or logical string Utf8, LargeUtf8, Utf8View vertex IDs; string vertex-identity outputs are canonicalized to Utf8 (native mapping Int64) while scores, distances, counts, coordinates, and opaque labels stay numeric. The shared vertex-ID contract is summarized in Vertex ID support; the concrete call-specific schema comes from gpu_validate_call.

Logical string side-input limitations:

  • edge ID columns and edge-ID predicate side inputs are not supported for logical string graphs

Arguments and options

Relation arguments

ArgumentRequiredColumnsDescription
edgesyes
  • src, dst: Int32, Int64, Utf8, LargeUtf8, Utf8View
  • weight (optional): Float32, Float64
  • edge_id (optional): Int32, Int64
edge relation with canonical src and dst columns, plus optional weight and edge_id columns

Every edge_id column must have the integer type of src and dst; string-keyed graphs accept no edge IDs.

Named value arguments

OptionTypeDefaultConstraintsDescription
degree_typestring"in_out"one of "in", "out", "in_out"degree direction

Graph construction options

This function requires directed=false (undirected/symmetric graph); all other graph construction options follow the shared defaults documented in Graph Construction Options.

Output

ColumnTypeNullableDescription
vertexInt64|Utf8noVertex whose core number is reported.
core_numberInt64noLargest k value for which the vertex belongs to the graph k-core.

These are generic descriptor schemas; run gpu_validate_call to get the concrete, table-specific output schema.

Examples

This example runs on the citation network demo dataset.

Find the densest citation core

Core number measures how deep a vertex sits in recursively denser subgraphs. The call builds an undirected graph, so a paper's degree is its number of distinct citation neighbors, whichever direction the citation points; every degree_type selector gives the same degree on that symmetric edge list. Define the result as a workspace view, find the deepest shell, and list its members:

CREATE OR REPLACE VIEW cores AS
SELECT vertex, core_number
FROM cugraph_core_number(edges => (SELECT src, dst FROM citation_edges));

SELECT core_number AS deepest, COUNT(*) AS members
FROM cores
WHERE core_number = (SELECT MAX(core_number) FROM cores)
GROUP BY core_number;
deepestmembers
355,913
SELECT p.year, p.title
FROM cores c JOIN papers p ON p.paper_id = c.vertex
WHERE c.core_number = (SELECT MAX(core_number) FROM cores)
ORDER BY p.n_citation DESC
LIMIT 6;
yeartitle
2004Distinctive Image Features from Scale-Invariant Keypoints
2001Random Forests
2011LIBSVM: A library for support vector machines
1995The Nature of Statistical Learning Theory
1995Support-Vector Networks
1986A Computational Approach to Edge Detection

The 35-core (5,913 papers, each linked by citation to at least 35 other members of the shell) is recognizably the machine-learning and computer-vision literature.

Limits

No algorithm-specific limitations.

To dry-run validate relation metadata, column types, and options without execution, see gpu_validate_call.