Skip to main content

Degrees All

SQL function: cugraph_degrees_all

Official cuGraph reference: Python API

Count both incoming and outgoing edges for every vertex in the graph.

Signature

cugraph_degrees_all(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_degrees_all('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 whose degree counts are reported.
in_degreeInt64noNumber of incoming edges for the vertex.
out_degreeInt64noNumber of outgoing edges for the vertex.

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

Examples

This example runs on the citation network demo dataset.

In-degree and out-degree in one call

One call returns in-degree and out-degree together, so a compound WHERE finds papers that are both heavy citers and heavily cited — comprehensive works that anchor a field and survey it at the same time:

SELECT d.in_degree, d.out_degree, p.year, p.title
FROM cugraph_degrees_all('citation_edges', 'src', 'dst') d
JOIN papers p ON p.paper_id = d.vertex
WHERE d.out_degree > 200 AND d.in_degree > 2000
ORDER BY d.in_degree DESC
LIMIT 4;
in_degreeout_degreeyeartitle
5,1154341996Handbook of Applied Cryptography
3,6662172002Machine learning in automated text categorization
2,9542402009Anomaly detection: A survey
2,5645642015Deep learning in neural networks

For a single direction with metadata comparisons, see cugraph_in_degrees_all and cugraph_out_degrees_all.

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_degrees_all',
'{"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.