Syntax overview

This section describes the general syntax for running algorithms in the Neo4j Graph Data Science library, including execution modes and common configuration parameters.

The general algorithm syntax comes in two variants:

  • Named graph variant

    • The graph to operate over will be read from the graph catalog.

  • Anonymous graph variant

    • The graph to operate over will be created and deleted as part of the algorithm execution.

Each syntax variant additionally provides different execution modes. These are the supported execution modes:

  • stream

    • Returns the result of the algorithm as a stream of records.

  • stats

    • Returns a single record of summary statistics, but does not write to the Neo4j database.

  • mutate

    • Writes the results of the algorithm to the in-memory graph and returns a single record of summary statistics. This mode is designed for the named graph variant, as its effects will be invisible on an anonymous graph.

  • write

    • Writes the results of the algorithm to the Neo4j database and returns a single record of summary statistics.

Finally, an execution mode may be estimated by appending the command with estimate.

Only the production-quality tier guarantees availability of all execution modes and estimation procedures.

Including all of the above mentioned elements leads to the following syntax outlines:

Syntax composition for the named graph variant:
CALL gds[.<tier>].<algorithm>.<execution-mode>[.<estimate>](
  graphName: String,
  configuration: Map
)
Syntax composition for the anonymous graph variant:
CALL gds[.<tier>].<algorithm>.<execution-mode>[.<estimate>](
  configuration: Map
)

The detailed sections in this chapter include concrete syntax overviews and examples.