SSSP
SQL function: cugraph_sssp
Compute single-source shortest paths.
Signature
cugraph_sssp(table_name, source_vertex [, src_col, dst_col [, weight_col [, options_json]]])
Allowed argument counts: 2, 4, 5, 6.
Quickstart
SELECT * FROM cugraph_sssp('target_edges', 123)
Positional arguments
| Argument | Type | Required | Default | Notes |
|---|---|---|---|---|
table_name | Utf8 | yes | ||
source_vertex | Int64 | yes | ||
src_col | Utf8 | no | src | |
dst_col | Utf8 | no | dst | |
weight_col | Utf8|null | no | optional edge weight column for graph construction when supported by the algorithm; semantic effect: edge weights affect algorithm results when provided | |
options_json | Utf8 | no |
JSON options
| Option | Type | Default | Constraints | Description |
|---|---|---|---|---|
cutoff | Float64|null | null | min 0 |
Graph construction options
Shared by all cuGraph functions, shown here with this function's defaults. The construction_policy option controls whether Nexus requests Python cuGraph-compatible edge normalization or bypasses it for raw libcugraph-style construction; see graph construction options for the full policy guide.
| Option | Type | Default | Constraints | Description |
|---|---|---|---|---|
construction_policy | Utf8 | "python_cugraph" | one of "python_cugraph", "raw_libcugraph" | Edge-list construction semantics used before calling libcugraph. |
directed | Boolean | true | Whether graph construction treats edges as directed. | |
renumber | Boolean | true | Whether graph construction may renumber external vertex identifiers internally. |
Output schema
| Column | Type | Nullable | Description |
|---|---|---|---|
vertex | Int64 | no | Vertex reached by the shortest-path traversal. |
distance | Float64 | no | Shortest weighted-path distance from the source vertex. |
predecessor | Int64 | yes | Previous vertex on the shortest-path tree, null for the source or unreachable vertices. |
These are the generic registry schemas. Run cugraph_validate_call for the concrete, table-specific output schema of a particular call.
Examples
This example runs on the citation network demo dataset.
SQL-derived edge weights: the time-cost of an idea
The citation edges carry a constant weight, but the weight column handed to
SSSP can be computed by SQL. Joining papers on both endpoints prices
each citation hop at the number of years it jumps back — so SSSP distance
becomes the cumulative "travel through time" along the cheapest reference
chain:
CREATE VIEW edges_time_cost AS
SELECT e.src, e.dst,
CAST(GREATEST(1, ps.year - pd.year) AS DOUBLE) AS weight
FROM citation_edges e
JOIN papers ps ON ps.paper_id = e.src
JOIN papers pd ON pd.paper_id = e.dst
WHERE ps.year > 1900 AND pd.year > 1900;
SELECT CAST(ROUND(s.distance) AS BIGINT) AS time_cost, p.year, p.title
FROM cugraph_sssp('edges_time_cost', 2963403868, 'src', 'dst', 'weight') s
JOIN papers p ON p.paper_id = s.vertex
WHERE s.distance < 1e300
ORDER BY p.year ASC, s.distance ASC
LIMIT 6;
| time_cost | year | title |
|---|---|---|
| 84 | 1933 | Algebraic Functions |
| 82 | 1935 | When is a Trigonometric Polynomial Not a Trigonometric Polynomial |
| 81 | 1936 | Correction to a Note on the Entscheidungsproblem |
| 81 | 1936 | Toward a Calculus of Concepts |
| 81 | 1936 | Set-Theoretic Foundations for Logic |
| 81 | 1936 | A System of Formal Logic without an Analogue to the Curry W. Operator |
Starting from Attention Is All You Need (2017), the cheapest reference
chains reach the 1936 foundations of computability and formal logic at a
time-cost of 81 years. The GREATEST(1, …) clamp keeps weights positive
(same-year and forward-dated citations cost 1), and the WHERE clause drops
the handful of bogus pre-1900 years in the source data. Unreached vertices
report an infinite distance, filtered here with s.distance < 1e300.
Limitations & notes
- dry-run validates table resolution, column presence, static dtypes, and options only
- dry-run does not scan edge data, construct a graph, or prove source-vertex existence
Validate before running
Always dry-run a call before executing it. Validation checks the function, table, columns, dtypes, and options without touching the GPU:
SELECT * FROM cugraph_validate_call(
'cugraph_sssp',
'your_edges_table',
'{"src_col":"src","dst_col":"dst"}'
);
See Discovery & validation for the full cugraph_validate_call contract.