Strongly Connected Components
UDTF: cugraph_strongly_connected_components
Official cuGraph reference: C API
Label maximal directed subgraphs in which every vertex is reachable from every other vertex.
Quickstart
The call below supplies edges from registered relation target_edges with canonical src and dst columns and may include weight.
SELECT *
FROM cugraph_strongly_connected_components(
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.
Graph construction options
Graph construction follows the shared defaults (directed=true, renumbering, python_cugraph policy) 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 mutually citing paper pairs have the largest publication-year gaps?
Before using citation direction as a timeline, inspect pairs whose references run both ways despite a large gap in publication years. A strongly connected component with two vertices contains such a pair. These are candidates for checking editions and publication metadata, not proof of an incorrect citation.
Save one SCC result so the pair selection and both paper lookups use labels from the same execution. The query excludes years outside 1900 through 2020 and returns one row per pair.
CREATE OR REPLACE TABLE scc_snapshot AS
SELECT vertex, component
FROM cugraph_strongly_connected_components(
edges => (SELECT src, dst FROM citation_edges), directed => true);
WITH pairs AS (
SELECT component FROM scc_snapshot GROUP BY component HAVING COUNT(*) = 2)
SELECT pa.year AS year_a, pa.title AS paper_a,
pb.year AS year_b, pb.title AS paper_b,
ABS(pa.year - pb.year) AS year_gap
FROM pairs x
JOIN scc_snapshot a ON a.component = x.component
JOIN scc_snapshot b ON b.component = x.component AND a.vertex < b.vertex
JOIN papers pa ON pa.paper_id = a.vertex
JOIN papers pb ON pb.paper_id = b.vertex
WHERE pa.year BETWEEN 1900 AND 2020 AND pb.year BETWEEN 1900 AND 2020
ORDER BY year_gap DESC, a.vertex, b.vertex
LIMIT 5;
The year gap prioritizes records for review. Larger strongly connected components can also contain mutual citations; this query selects isolated two-paper components to keep each case directly inspectable.