Skip to main content

Strongly Connected Components

SQL function: cugraph_strongly_connected_components

Official cuGraph reference: C API

Label maximal directed subgraphs in which every vertex is reachable from every other vertex.

Signature

cugraph_strongly_connected_components(table_name [, src_col, dst_col [, weight_col [, options_json]]])

Quickstart

The call below expects a registered edge table or view target_edges with endpoint columns src and dst. Substitute your own registered relations.

SELECT * FROM cugraph_strongly_connected_components('target_edges');

Inputs

table_name must be a registered edge table or view (the edges role); parenthesized subqueries are not accepted, and metadata validation resolves the same registered name.

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

Positional scalar arguments

src_col and dst_col name the edge endpoint columns; both are optional and default to src and dst.

ArgumentTypeRequiredDefaultNotes
weight_colUtf8|nullnoaccepted as an edge-column binding; native algorithm execution does not consume weights; semantic effect: none for this algorithm

JSON options

This function has no algorithm-specific options.

Graph construction options

Graph construction follows the shared defaults (directed=true, renumbering, python_cugraph policy) documented in Graph Construction Options.

Output

ColumnTypeNullableDescription
vertexInt64|Utf8noVertex assigned to a strongly connected component.
labelInt64noStrongly connected component identifier for the vertex: the minimum vertex id in the component, stable across runs.

These are generic descriptor schemas; validate the call to get the concrete, table-specific output schema.

Examples

These examples run on the citation network demo dataset.

Count multi-paper strongly connected components

A citation normally points from a newer paper to an older one, so a directed cycle of citations is an anomaly: two or more papers that cite each other directly or transitively. Such a group forms a strongly connected component of more than one vertex. SCC finds every component in one pass. Snapshot the run in the mutable datafusion.public workspace (labels are assigned per execution), then count the multi-paper components:

-- Local workspace snapshot; this does not write to lake.citation_network.
CREATE TABLE scc_snapshot AS
SELECT vertex, label
FROM cugraph_strongly_connected_components('citation_edges', 'src', 'dst', NULL,
'{"directed":true}');

WITH loops AS (
SELECT label, COUNT(*) AS members FROM scc_snapshot
GROUP BY label HAVING COUNT(*) > 1)
SELECT COUNT(*) AS loops, MAX(members) AS biggest, SUM(members) AS papers_in_loops
FROM loops;
loopsbiggestpapers_in_loops
14,6131,370,0291,404,311

The notable result is the largest component: 1.37M papers sit inside one strongly connected component. Preprint/journal duplicate versions, simultaneous publication, and metadata errors introduce enough forward-dated citations — a newer paper cited by an older one — to bind roughly a third of the graph into a single component. These apparent forward-in-time citations are a structural feature of bibliographic data.

Inspect the two-paper cycles

WITH pairs AS (
SELECT label FROM scc_snapshot GROUP BY label HAVING COUNT(*) = 2)
SELECT c.label, p.year, p.title
FROM pairs x
JOIN scc_snapshot c ON c.label = x.label
JOIN papers p ON p.paper_id = c.vertex
ORDER BY c.label
LIMIT 6;
labelyeartitle
572017Index Modulation Techniques for Next-Generation Wireless Networks
572017Multidimensional index modulation in wireless communications
2102017A Survey of Research into Mixed Criticality Systems
2102017Probabilistic analysis for mixed criticality systems using fixed priority…
2652018DC programming and DCA: thirty years of developments
2652018Convergence Analysis of Difference-of-Convex Algorithm with Subanalytic Data

12,015 of the 14,613 cycles are exactly two papers — same-year companion papers and surveys citing each other, the typical form of mutual citation in practice.

Limits

No algorithm-specific limitations.

Validate the call

Dry-run validation checks registered relation metadata, column presence, static dtypes, and options only; it does not scan edge data, construct a graph, or prove source-vertex existence:

SELECT * FROM gpu_validate_call(
'cugraph_strongly_connected_components',
'{"schema_version":1,"relations":{"edges":{"table":"target_edges"}},"options":{"src_col":"src","dst_col":"dst"}}'
);

See GPU Function Catalog API for the full gpu_validate_call contract.