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
| Argument | Required | Columns | Description |
|---|---|---|---|
edges | yes |
| 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
| Option | Type | Default | Constraints | Description |
|---|---|---|---|---|
degree_type | string | "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
| Column | Type | Nullable | Description |
|---|---|---|---|
vertex | Int64|Utf8 | no | Vertex whose core number is reported. |
core_number | Int64 | no | Largest 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;
| deepest | members |
|---|---|
| 35 | 5,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;
| year | title |
|---|---|
| 2004 | Distinctive Image Features from Scale-Invariant Keypoints |
| 2001 | Random Forests |
| 2011 | LIBSVM: A library for support vector machines |
| 1995 | The Nature of Statistical Learning Theory |
| 1995 | Support-Vector Networks |
| 1986 | A 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.