GraphSAGE unsupervised (AGA-only)

This algorithm is only available in Aura Graph Analytics.

Glossary

Directed

Directed trait. The algorithm is well-defined on a directed graph.

Directed

Directed trait. The algorithm ignores the direction of the graph.

Directed

Directed trait. The algorithm does not run on a directed graph.

Undirected

Undirected trait. The algorithm is well-defined on an undirected graph.

Undirected

Undirected trait. The algorithm ignores the undirectedness of the graph.

Heterogeneous nodes

Heterogeneous nodes fully supported. The algorithm has the ability to distinguish between nodes of different types.

Heterogeneous nodes

Heterogeneous nodes allowed. The algorithm treats all selected nodes similarly regardless of their label.

Heterogeneous relationships

Heterogeneous relationships fully supported. The algorithm has the ability to distinguish between relationships of different types.

Heterogeneous relationships

Heterogeneous relationships allowed. The algorithm treats all selected relationships similarly regardless of their type.

Weighted relationships

Weighted trait. The algorithm supports a relationship property to be used as weight, specified via the relationshipWeightProperty configuration parameter.

Weighted relationships

Weighted trait. The algorithm treats each relationship as equally important, discarding the value of any relationship weight.

Node properties

Node properties trait. The algorithm makes use of node properties.

Introduction

GraphSAGE is a graph neural network (GNN) architecture outlined in the paper Inductive Representation Learning on Large Graphs by Hamilton et al. (2017).

This section covers the syntax used to execute the GraphSAGE algorithm to generate unsupervised embeddings for nodes in a graph.

For node classification, see GraphSAGE supervised.
GraphSAGE unsupervised syntax per mode
Run GraphSAGE unsupervised in train mode on a named graph.
CALL gds.graphSage.unsupervised.train(
  graphName: String,
  configuration: Map
)
YIELD
  preProcessingMillis: Integer,
  trainMillis: Integer,
  configuration: Map
Table 1. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 2. Configuration
Name Type Default Optional Description

activationFunction

String

"relu"

yes

The activation function to use. Valid values are "relu" and "sigmoid"

aggregator

String

"mean"

yes

The neighborhood embedding aggregator to use. Valid values are "mean" and "max"

batchSize

Integer

n/a

yes

The number of target nodes to train on in each batch. If not provided, the algorithm will automatically infer the maximally allowed batch size within the constraints of available memory

dropout

Float

0.1

yes

The dropout probability for each layer. Must be a value >= 0.0 and < 1.0

embeddingDimension

Integer

256

yes

The node embedding dimension of the model layers' outputs

epochs

Integer

n/a

no

The number of epochs to train the model

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID to more easily track the algorithm’s progress.

layerNormalization

Boolean

true

yes

Whether to apply layer normalization between the model layers

learningRate

Float

0.001

yes

The learning rate for the optimizer

modelName

String

n/a

no

The name of the model to train (must be unique)

negativeSamplingRatio

Float

1.0

yes

The ratio of negative to positive samples to sample for training

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

numNeighbors

List

[20, 10]

yes

The number of neighbors to sample for each layer. Note that this also determines the number of layers

numWalks

Integer

10

yes

The number of random walks to perform for each node in the graph

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types. Relationships with any of the given types will be included.

walkDepth

Integer

3

yes

The number of steps in every random walk

Table 3. Results
Name Type Description

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

trainMillis

Integer

Milliseconds to train the model.

configuration

Map

The configuration used for running the algorithm.

Run GraphSAGE unsupervised in stream mode on a named graph.
CALL gds.graphSage.unsupervised.stream(
  graphName: String,
  configuration: Map
)
YIELD
  embedding: List,
  nodeId: Integer
Table 4. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 5. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE unsupervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

Table 6. Results
Name Type Description

embedding

List of Float

The computed node embedding.

nodeId

Integer

Node ID.

Run GraphSAGE unsupervised in mutate mode on a graph stored in the catalog.
CALL gds.graphSage.unsupervised.mutate(
  graphName: String,
  configuration: Map
)
YIELD
  computeMillis: Integer,
  mutateMillis: Integer,
  nodePropertiesWritten: Integer,
  preProcessingMillis: Integer,
  configuration: Map
Table 7. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 8. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE unsupervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

mutateProperty

String

n/a

no

The node property in the GDS graph to which the embedding is written.

Table 9. Results
Name Type Description

computeMillis

Integer

Milliseconds for running the algorithm.

mutateMillis

Integer

Milliseconds for adding properties to the projected graph.

nodePropertiesWritten

Integer

Number of properties added to the projected graph.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

configuration

Map

The configuration used for running the algorithm.

Run GraphSAGE unsupervised in write mode on a graph stored in the catalog.
CALL gds.graphSage.unsupervised.write(
  graphName: String,
  configuration: Map
)
YIELD
  computeMillis: Integer,
  nodePropertiesWritten: Integer,
  preProcessingMillis: Integer,
  writeMillis: Integer,
  configuration: Map
Table 10. Parameters
Name Type Default Optional Description

graphName

String

n/a

no

The name of a graph stored in the catalog.

configuration

Map

{}

yes

Configuration for algorithm-specifics and/or graph filtering.

Table 11. Configuration
Name Type Default Optional Description

batchSize

Integer

n/a

yes

The number of nodes per batch.

featureProperties

List of String

n/a

no

The names of the node properties that should be used as input features. All property names must exist in the projected graph and be of type Float or List of Float.

jobId

String

Generated internally

yes

An ID that can be provided to more easily track the algorithm’s progress.

modelName

String

n/a

no

The name of a GraphSAGE unsupervised model in the model catalog.

nodeLabels

List of String

["*"]

yes

Filter the named graph using the given node labels. Nodes with any of the given labels will be included.

randomSeed

String

n/a

yes

A number used to seed all randomness of the computation

relationshipTypes

List of String

["*"]

yes

Filter the named graph using the given relationship types.

writeConcurrency

String

'concurrency'

yes

The number of concurrent threads used for writing the node properties.

writeProperty

String

n/a

no

The node property in the Neo4j database to which the embedding is written

Table 12. Results
Name Type Description

computeMillis

Integer

Milliseconds for running the algorithm.

nodePropertiesWritten

Integer

Number of properties added to the projected graph.

preProcessingMillis

Integer

Milliseconds for preprocessing the graph.

writeMillis

Integer

Milliseconds for writing result data back.

configuration

Map

The configuration used for running the algorithm.