Skip to main content

Core Number

UDTF: 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.

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.

The vertex-ID types this UDTF accepts, the numeric types a per-call codebook maps to native ids, and its string-key limits are listed in Vertex ID support; the concrete call-specific schema comes from gpu_validate_call.

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; this algorithm ignores weight

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 UDTF 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.

Which papers belong to the most densely connected citation core?​

A reading list can start with papers embedded in a mutually connected body of work. The deepest core is the subgraph with the largest minimum number of distinct citation neighbors. Citation direction is ignored here. This query finds that core, counts its members, and lists its most-cited papers using the corpus's citation-count metadata.

WITH cores AS (
SELECT vertex, core_number
FROM cugraph_core_number(edges => (SELECT src, dst FROM citation_edges))),
shells AS (
SELECT vertex, core_number, MAX(core_number) OVER () AS deepest
FROM cores),
members AS (
SELECT vertex, core_number, COUNT(*) OVER () AS members
FROM shells WHERE core_number = deepest)
SELECT c.core_number, c.members, p.year, p.title
FROM members c JOIN papers p ON p.paper_id = c.vertex
ORDER BY p.n_citation DESC, p.paper_id
LIMIT 6;
core_numbermembersyeartitle
3559132004Distinctive Image Features from Scale-Invariant Keypoints
3559132001Random Forests
3559132011LIBSVM: A library for support vector machines
3559131995The Nature of Statistical Learning Theory
3559131995Support-Vector Networks
3559131986A Computational Approach to Edge Detection

Every member of this core has at least core_number neighbors inside it. The count includes citations in either direction. It does not require each paper to cite that many other members. To extract the edges for a reading map, see the k-core example.