K-Core
UDTF: cugraph_k_core
Official cuGraph reference: C API
Return the edges of the maximal subgraph whose vertices each have 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_k_core(
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
Every edge_id column must have the integer type of src and dst; string-keyed graphs accept no edge IDs.
Named value arguments
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
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 stand out inside the densely connected citation core?
The k=30 core keeps papers with at least 30 neighbors inside the core when citation links are treated as undirected. Its edge output is symmetrized, so a retained neighbor pair appears in both directions. This threshold counts undirected neighbors, not at least 30 citations received and 30 references made by every paper. The nested call passes the core directly to PageRank and returns its five highest-scoring papers:
SELECT p.year, p.title
FROM cugraph_pagerank(edges => (
SELECT src, dst
FROM cugraph_k_core(
edges => (SELECT src, dst FROM citation_edges), k => 30)
)) r
JOIN papers p ON p.paper_id = r.vertex
ORDER BY r.value DESC
LIMIT 5;