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

The deepest core has 5,913 papers at core number 35, and SIFT ranks first by reported citation count among its members.

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.

Limits​

No algorithm-specific limitations.

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