# Fast Random Projection

This section describes the Fast Random Projection (FastRP) node embedding algorithm in the Neo4j Graph Data Science library.

## 1. Introduction

Fast Random Projection, or FastRP for short, is a node embedding algorithm in the family of random projection algorithms. These algorithms are theoretically backed by the Johnsson-Lindenstrauss lemma according to which one can project n vectors of arbitrary dimension into O(log(n)) dimensions and still approximately preserve pairwise distances among the points. In fact, a linear projection chosen in a random way satisfies this property.

Such techniques therefore allow for aggressive dimensionality reduction while preserving most of the distance information. The FastRP algorithm operates on graphs, in which case we care about preserving similarity between nodes and their neighbors. This means that two nodes that have similar neighborhoods should be assigned similar embedding vectors. Conversely, two nodes that are not similar should be not be assigned similar embedding vectors.

The FastRP algorithm initially assigns random vectors to all nodes using a technique called very sparse random projection, see (Achlioptas, 2003) below. The algorithm then iteratively constructs intermediate embeddings by averaging either neighboring intermediate embeddings from the previous iteration, or the generated random vectors during the first iteration. In each iteration, the intermediate embedding is normalised using a standard euclidean norm. That is, each element in the embedding is divided by the square root of the sum of squares of the emdedding elements.

In the end, the resulting embedding for each node is a weighted sum of the intermediate embeddings, where the weights are a configuration parameter called `iterationWeights`.

Therefore, each node’s embedding depends on a neighborhood of radius equal to the number of iterations. This way FastRP exploits higher-order relationships in the graph while still being highly scalable.

The present implementation extends the original algorithm to support weighted graphs, which computes weighted averages of neighboring embeddings using the relationship weights. In order to make use of this, the `relationshipWeightProperty` parameter should be set to an existing relationship property.

The original algorithm is intended only for undirected graphs. We support running on both on directed graphs and undirected graph. For directed graphs we consider only the outgoing neighbors when computing the intermediate embeddings for a node. Therefore, using the orientations `NATURAL`, `REVERSE` or `UNDIRECTED` will all give different embeddings. In general, it is recommended to first use `UNDIRECTED` as this is what the original algorithm was evaluated on.

## 2. Tuning algorithm parameters

In order to improve the embedding quality using FastRP on one of your graphs, it is possible to tune the algorithm parameters. This process of finding the best parameters for your specific use case and graph is typically referred to as hyperparameter tuning. We will go through each of the configuration parameters and explain how they behave.

For statistically sound results, it is a good idea to reserve a test set excluded from parameter tuning. After selecting a set of parameter values, the embedding quality can be evaluated using a downstream machine learning task on the test set. By varying the parameter values and studying the precision of the machine learning task, it is possible to deduce the parameter values that best fit the concrete dataset and use case. To construct such a set you may want to use a dedicated node label in the graph to denote a subgraph without the test data.

### 2.1. Embedding dimension

The embedding dimension is the length of the produced vectors. A greater dimension offers a greater precision, but is more costly to operate over.

The optimal embedding dimension depends on the number of nodes in the graph. Since the amount of information the embedding can encode is limited by its dimension, a larger graph will tend to require a greater embedding dimension. A typical value is a power of two in the range 128 - 1024. A value of at least 256 gives good results on graphs in the order of 105 nodes, but in general increasing the dimension improves results. Increasing embedding dimension will however increase memory requirements and runtime linearly.

### 2.2. Normalization strength

The normalization strength is used to control how node degrees influence the embedding. Using a negative value will downplay the importance of high degree neighbors, while a positive value will instead increase their importance. The optimal normalization strength depends on the graph and on the task that the embeddings will be used for. In the original paper, hyperparameter tuning was done in the range of `[-1,0]` (no positive values), but we have found cases where a positive normalization strengths gives better results.

### 2.3. Iteration weights

The iteration weights parameter control two aspects: the number of iterations, and their relative impact on the final node embedding. The parameter is a list of numbers, indicating one iteration per number where the number is the weight applied to that iteration.

In each iteration, the algorithm will expand across all relationships in the graph. This has some implications:

• With a single iteration, only direct neighbors will be considered for each node embedding.

• With two iterations, direct neighbors and second-degree neighbors will be considered for each node embedding.

• With three iterations, direct neighbors, second-degree neighbors, and third-degree neighbors will be considered for each node embedding. Direct neighbors may be reached twice, in different iterations.

• In general, the embedding corresponding to the `i`:th iteration contains features depending on nodes reachable with paths of length `i`. If the graph is undirected, then a node reachable with a path of length `L` can also be reached with length `L+2k`, for any integer `k`.

• In particular, a node may reach back to itself on each even iteration (depending on the direction in the graph).

It is good to have at least one non-zero weight in an even and in an odd position. Typically, using at least a few iterations, for example three, is recommended. However, a too high value will consider nodes far away and may not be informative or even be detrimental. The intuition here is that as the projections reach further away from the node, the less specific the neighborhood becomes. Of course, a greater number of iterations will also take more time to complete.

### 2.4. Orientation

Choosing the right orientation when creating the graph may have the single greatest impact. The FastRP algorithm is designed to work with undirected graphs, and we expect this to be the best in most cases. If you expect only outgoing or incoming relationships to be informative for a prediction task, then you may want to try using the orientations `NATURAL` or `REVERSE` respectively.

## 3. Syntax

This section covers the syntax used to execute the FastRP algorithm in each of its execution modes. We are describing the named graph variant of the syntax. To learn more about general syntax variants, see Syntax overview.

Example 1. FastRP syntax per mode
Run FastRP in stream mode on a named graph.
``````CALL gds.fastRP.stream(
graphName: String,
configuration: Map
) YIELD
nodeId: Integer,
embedding: List<Float>``````
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. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

Table 3. Algorithm specific configuration
Name Type Default Optional Description

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 4. Results
Name Type Description

nodeId

Integer

Node ID.

embedding

List<Float>

FastRP node embedding.

Run FastRP in stats mode on a named graph.
``````CALL gds.fastRP.stats(
graphName: String,
configuration: Map
) YIELD
nodeCount: Integer,
createMillis: Integer,
computeMillis: Integer,
configuration: Map``````
Table 5. 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 6. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

Table 7. Algorithm specific configuration
Name Type Default Optional Description

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 8. Results
Name Type Description

nodeCount

Integer

Number of nodes processed.

createMillis

Integer

Milliseconds for creating the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

configuration

Map

Configuration used for running the algorithm.

Run FastRP in mutate mode on a named graph.
``````CALL gds.fastRP.mutate(
graphName: String,
configuration: Map
) YIELD
nodeCount: Integer,
nodePropertiesWritten: Integer,
createMillis: Integer,
computeMillis: Integer,
mutateMillis: Integer,
configuration: Map``````
Table 9. 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 10. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

mutateProperty

String

`n/a`

no

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

Table 11. Algorithm specific configuration
Name Type Default Optional Description

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 12. Results
Name Type Description

nodeCount

Integer

Number of nodes processed.

nodePropertiesWritten

Integer

Number of node properties written.

createMillis

Integer

Milliseconds for creating the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

mutateMillis

Integer

Milliseconds for adding properties to the in-memory graph.

configuration

Map

Configuration used for running the algorithm.

Run FastRP in write mode on a named graph.
``````CALL gds.fastRP.write(
graphName: String,
configuration: Map
) YIELD
nodeCount: Integer,
propertiesWritten: Integer,
createMillis: Integer,
computeMillis: Integer,
writeMillis: Integer,
configuration: Map``````
Table 13. 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 14. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm. Also provides the default value for 'writeConcurrency'.

writeConcurrency

Integer

`value of 'concurrency'`

yes

The number of concurrent threads used for writing the result to Neo4j.

writeProperty

String

`n/a`

no

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

Table 15. Algorithm specific configuration
Name Type Default Optional Description

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 16. Results
Name Type Description

nodeCount

Integer

Number of nodes processed.

nodePropertiesWritten

Integer

Number of node properties written.

createMillis

Integer

Milliseconds for creating the graph.

computeMillis

Integer

Milliseconds for running the algorithm.

writeMillis

Integer

Milliseconds for writing result data back to Neo4j.

configuration

Map

Configuration used for running the algorithm.

### 3.1. Anonymous graphs

It is also possible to execute the algorithm on a graph that is projected in conjunction with the algorithm execution. In this case, the graph does not have a name, and we call it anonymous. When executing over an anonymous graph the configuration map contains a graph projection configuration as well as an algorithm configuration. All execution modes support execution on anonymous graphs, although we only show syntax and mode-specific configuration for the `write` mode for brevity.

Run FastRP in write mode on an anonymous graph.
``````CALL gds.fastRP.write(
configuration: Map
)
YIELD
nodeCount: Integer,
nodePropertiesWritten: Integer,
createMillis: Integer,
computeMillis: Integer,
writeMillis: Integer,
configuration: Map``````
Table 17. General configuration for algorithm execution on an anonymous graph.
Name Type Default Optional Description

nodeProjection

String, String[] or Map

`null`

yes

The node projection used for anonymous graph creation via a Native projection.

relationshipProjection

String, String[] or Map

`null`

yes

The relationship projection used for anonymous graph creation a Native projection.

nodeQuery

String

`null`

yes

The Cypher query used to select the nodes for anonymous graph creation via a Cypher projection.

relationshipQuery

String

`null`

yes

The Cypher query used to select the relationships for anonymous graph creation via a Cypher projection.

nodeProperties

String, String[] or Map

`null`

yes

The node properties to project during anonymous graph creation.

relationshipProperties

String, String[] or Map

`null`

yes

The relationship properties to project during anonymous graph creation.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm. Also provides the default value for 'readConcurrency' and 'writeConcurrency'.

Integer

`value of 'concurrency'`

yes

The number of concurrent threads used for creating the graph.

writeConcurrency

Integer

`value of 'concurrency'`

yes

WRITE mode only: The number of concurrent threads used for writing the result.

writeProperty

String

`n/a`

no

WRITE mode only: The node property to which the embedding is written to.

Table 18. Algorithm specific configuration
Name Type Default Optional Description

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

If set, the values stored at the given property are used as relationship weights during the computation. If not set, the graph is considered unweighted.

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

The results are the same as for running write mode with a named graph, see the write mode syntax above.

## 4. Examples

In this section we will show examples of running the FastRP node embedding algorithm on a concrete graph. The intention is to illustrate what the results look like and to provide a guide in how to make use of the algorithm in a real setting. We will do this on a small social network graph of a handful nodes connected in a particular pattern. The example graph looks like this:

The following Cypher statement will create the example graph in the Neo4j database:
``````CREATE
(dan:Person {name: 'Dan'}),
(annie:Person {name: 'Annie'}),
(matt:Person {name: 'Matt'}),
(jeff:Person {name: 'Jeff'}),
(brie:Person {name: 'Brie'}),
(elsa:Person {name: 'Elsa'}),
(john:Person {name: 'John'}),

(dan)-[:KNOWS {weight: 1.0}]->(annie),
(dan)-[:KNOWS {weight: 1.0}]->(matt),
(annie)-[:KNOWS {weight: 1.0}]->(matt),
(annie)-[:KNOWS {weight: 1.0}]->(jeff),
(annie)-[:KNOWS {weight: 1.0}]->(brie),
(matt)-[:KNOWS {weight: 3.5}]->(brie),
(brie)-[:KNOWS {weight: 1.0}]->(elsa),
(brie)-[:KNOWS {weight: 2.0}]->(jeff),
(john)-[:KNOWS {weight: 1.0}]->(jeff);``````

This graph represents seven people who know one another. A relationship property `weight` denotes the strength of the knowledge between two persons.

With the graph in Neo4j we can now project it into the graph catalog to prepare it for algorithm execution. We do this using a native projection targeting the `Person` nodes and the `KNOWS` relationships. For the relationships we will use the `UNDIRECTED` orientation. This is because the FastRP algorithm has been measured to compute more predictive node embeddings in undirected graphs. We will also add the `weight` relationship property which we will make use of when running the weighted version of FastRP.

 In the examples below we will use named graphs and native projections as the norm. However, anonymous graphs and/or Cypher projections can also be used.
The following statement will create a graph using a native projection and store it in the graph catalog under the name 'persons'.
``````CALL gds.graph.create(
'persons',
'Person',
{
KNOWS: {
orientation: 'UNDIRECTED',
properties: 'weight'
}
})``````

### 4.1. Memory Estimation

First off, we will estimate the cost of running the algorithm using the `estimate` procedure. This can be done with any execution mode. We will use the `stream` mode in this example. Estimating the algorithm is useful to understand the memory impact that running the algorithm on your graph will have. When you later actually run the algorithm in one of the execution modes the system will perform an estimation. If the estimation shows that there is a very high probability of the execution going over its memory limitations, the execution is prohibited. To read more about this, see Automatic estimation and execution blocking.

For more details on `estimate` in general, see Memory Estimation.

The following will estimate the memory requirements for running the algorithm:
``````CALL gds.fastRP.stream.estimate('persons', {embeddingDimension: 128})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory``````
Table 19. Results
nodeCount relationshipCount bytesMin bytesMax requiredMemory

7

18

11400

11400

"11400 Bytes"

### 4.2. Stream

In the `stream` execution mode, the algorithm returns the embedding for each node. This allows us to inspect the results directly or post-process them in Cypher without any side effects. For example, we can collect the results and pass them into a similarity algorithm.

For more details on the `stream` mode in general, see Stream.

The following will run the algorithm, and stream results:
``````CALL gds.fastRP.stream('persons', { embeddingDimension: 4 })
YIELD nodeId, embedding``````
Table 20. Results
nodeId embedding

0

[-0.03523557, 0.8080418, -1.6324315, -0.82438976]

1

[7.3822774E-4, 0.9315331, -1.5840955, -0.73341024]

2

[-0.047208663, 0.80095035, -1.5542624, -0.8575211]

3

[0.06738296, 0.7497308, -1.4601052, -0.8149969]

4

[-0.0044725314, 1.0199871, -1.441534, -0.72904325]

5

[-0.15570015, 0.9881253, -1.4144595, -0.73383045]

6

[0.24555062, 0.7544494, -1.4108207, -0.65637124]

The results of the algorithm are not very intuitively interpretable, as the node embedding format is a mathematical abstraction of the node within its neighborhood, designed for machine learning programs. What we can see is that the embeddings have four elements (as configured using `embeddingDimension`) and that the numbers are relatively small (they all fit in the range of `[-2, 2]`). The magnitude of the numbers is controlled by the `embeddingDimension`, the number of nodes in the graph, and by the fact that FastRP performs euclidean normalization on the intermediate embedding vectors.

 Due to the random nature of the algorithm the results will vary between the runs. However, this does not necessarily mean that the pairwise distances of two node embeddings vary as much.

### 4.3. Stats

In the `stats` execution mode, the algorithm returns a single row containing a summary of the algorithm result. This execution mode does not have any side effects. It can be useful for evaluating algorithm performance by inspecting the `computeMillis` return item. In the examples below we will omit returning the timings. The full signature of the procedure can be found in the syntax section.

For more details on the `stats` mode in general, see Stats.

The following will run the algorithm and returns the result in form of statistical and measurement values
``````CALL gds.fastRP.stats('persons', { embeddingDimension: 8 })
YIELD nodeCount``````
Table 21. Results
nodeCount

7

The `stats` mode does not currently offer any statistical results for the embeddings themselves. We can however see that the algorithm has successfully processed all seven nodes in our example graph.

### 4.4. Mutate

The `mutate` execution mode extends the `stats` mode with an important side effect: updating the named graph with a new node property containing the embedding for that node. The name of the new property is specified using the mandatory configuration parameter `mutateProperty`. The result is a single summary row, similar to `stats`, but with some additional metrics. The `mutate` mode is especially useful when multiple algorithms are used in conjunction.

For more details on the `mutate` mode in general, see Mutate.

The following will run the algorithm in `mutate` mode:
``````CALL gds.fastRP.mutate(
'persons',
{
embeddingDimension: 8,
mutateProperty: 'fastrp-embedding'
}
)
YIELD nodePropertiesWritten``````
Table 22. Results
nodePropertiesWritten

7

The returned result is similar to the `stats` example. Additionally, the graph 'persons' now has a node property `fastrp-embedding` which stores the node embedding for each node. To find out how to inspect the new schema of the in-memory graph, see :/management-ops/graph-catalog-ops/index.adoc#catalog-graph-list.

### 4.5. Write

The `write` execution mode extends the `stats` mode with an important side effect: writing the embedding for each node as a property to the Neo4j database. The name of the new property is specified using the mandatory configuration parameter `writeProperty`. The result is a single summary row, similar to `stats`, but with some additional metrics. The `write` mode enables directly persisting the results to the database.

For more details on the `write` mode in general, see Write.

The following will run the algorithm in `write` mode:
``````CALL gds.fastRP.write(
'persons',
{
embeddingDimension: 8,
writeProperty: 'fastrp-embedding'
}
)
YIELD nodePropertiesWritten``````
Table 23. Results
nodePropertiesWritten

7

The returned result is similar to the `stats` example. Additionally, each of the seven nodes now has a new property `fastrp-embedding` in the Neo4j database, containing the node embedding for that node.

### 4.6. Weighted

By default, the algorithm is considering the relationships of the graph to be unweighted. To change this behaviour we can use configuration parameter called `relationshipWeightProperty`. Below is an example of running the weighted variant of algorithm.

The following will run the algorithm, and stream results:
``````CALL gds.fastRP.stream(
'persons',
{
embeddingDimension: 4,
relationshipWeightProperty: 'weight'
}
)
YIELD nodeId, embedding``````
Table 24. Results
nodeId embedding

0

[-0.55106115, 1.6823332, -0.66182184, -0.57873607]

1

[-0.38195288, 1.7911794, -0.54085857, -0.5870274]

2

[-0.4431507, 1.7395904, -0.4842358, -0.6109262]

3

[0.0018629134, 1.8233799, -0.3473827, -0.56145287]

4

[-0.2862969, 1.8058168, -0.4418158, -0.51601917]

5

[-0.26784867, 1.8103647, -0.28934777, -0.5363705]

6

[0.14821936, 1.8630133, -0.13068157, -0.46493164]

Since the initial state of the algorithm is randomised, it isn’t possible to intuitively analyse the effect of the relationship weights.

## 5. Extended Algorithm: Using Node Properties

The following aspects of the algorithm are in the beta tier. For more information on algorithm tiers, see Algorithms.

Most real-world graphs contain node properties which store information about the nodes and what they represent. An embedding algorithm which can process the node properties as features and incorporate them in the embeddings can therefore be advantageous.

The extended FastRP algorithm (FastRPExtended) has the additional configuration parameters `featureProperties` and `propertyDimension`. Each node property specified in the former is associated with a randomly generated vector of dimension `propertyDimension`. Each node is then initialized with a vector of size `embeddingDimension` formed by concatenation of two parts: The first part is formed like in the original algorithm, and the second one is a linear combination of the property vectors, using the property values of the node as weights. The algorithm then proceeds with the same logic as the original one. Therefore, the algorithm will output arrays of size `embeddingDimension` just like the original algorithm. The last `propertyDimension` co-ordinates in the embedding captures information about property values of nearby nodes, and the remaining co-ordinates (`embeddingDimension` - `propertyDimension` of them) captures information about nearby presence of nodes.

As other configuration parameters, `propertyDimension` needs to be tuned for optimal performance. We suggest keeping the previously selected value for `embeddingDimension` and setting `propertyDimension` to half that value as a starting point for using FastRPExtended. Other factors that may influence the choice of `propertyDimension` are vaguely the amount of valuable information contained in the node properties, i.e. number of properties and how independent they are, as well as how relevant the properties are to the problem at hand.

Example 2. FastRPExtended syntax per mode
Run FastRPExtended in stream mode on a named graph.
``````CALL gds.beta.fastRPExtended.stream(
graphName: String,
configuration: Map
) YIELD
nodeId: Integer,
embedding: List<Float>``````
Table 25. 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 26. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

Table 27. Algorithm specific configuration
Name Type Default Optional Description

propertyDimension

Integer

`0`

yes

The dimension of the projected node properties. Maximum value is `embeddingDimension`.

featureProperties

List<String>

`[]`

yes

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

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

The name of the relationship property used for weighted random projection

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 28. Results
Name Type Description

`nodeId`

Integer

The Neo4j node ID.

`embedding`

List<Float>

The computed node embedding.

Run FastRPExtended in stats mode on a graph stored in the catalog.
``````CALL gds.beta.fastRPExtended.stats(
graphName: String,
configuration: Map
)
YIELD
nodeCount: Integer,
createMillis: Integer,
computeMillis: Integer,
configuration: Map``````
Table 29. 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 30. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

Table 31. Algorithm specific configuration
Name Type Default Optional Description

propertyDimension

Integer

`0`

yes

The dimension of the projected node properties. Maximum value is `embeddingDimension`.

featureProperties

List<String>

`[]`

yes

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

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

The name of the relationship property used for weighted random projection

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 32. Results
Name Type Description

nodeCount

Integer

The number of nodes processed.

createMillis

Integer

computeMillis

Integer

Milliseconds for running the algorithm.

configuration

Map

The configuration used for running the algorithm.

Run FastRPExtended in mutate mode on a graph stored in the catalog.
``````CALL gds.beta.fastRPExtended.mutate(
graphName: String,
configuration: Map
)
YIELD
nodeCount: Integer,
nodePropertiesWritten: Integer,
createMillis: Integer,
computeMillis: Integer,
mutateMillis: Integer,
configuration: Map``````
Table 33. 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 34. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm.

mutateProperty

String

`n/a`

no

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

Table 35. Algorithm specific configuration
Name Type Default Optional Description

propertyDimension

Integer

`0`

yes

The dimension of the projected node properties. Maximum value is `embeddingDimension`.

featureProperties

List<String>

`[]`

yes

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

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

The name of the relationship property used for weighted random projection

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 36. Results
Name Type Description

nodeCount

Integer

The number of nodes processed.

nodePropertiesWritten

Integer

The number of node properties written.

createMillis

Integer

computeMillis

Integer

Milliseconds for running the algorithm.

mutateMillis

Integer

Milliseconds for adding properties to the in-memory graph.

configuration

Map

The configuration used for running the algorithm.

Run FastRPExtended in write mode on a graph stored in the catalog.
``````CALL gds.beta.fastRPExtended.write(
graphName: String,
configuration: Map
)
YIELD
nodeCount: Integer,
nodePropertiesWritten: Integer,
createMillis: Integer,
computeMillis: Integer,
writeMillis: Integer,
configuration: Map``````
Table 37. 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 38. General configuration for algorithm execution on a named graph.
Name Type Default Optional Description

nodeLabels

String[]

`['*']`

yes

Filter the named graph using the given node labels.

relationshipTypes

String[]

`['*']`

yes

Filter the named graph using the given relationship types.

concurrency

Integer

`4`

yes

The number of concurrent threads used for running the algorithm. Also provides the default value for 'writeConcurrency'.

writeConcurrency

Integer

`value of 'concurrency'`

yes

The number of concurrent threads used for writing the result to Neo4j.

writeProperty

String

`n/a`

no

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

Table 39. Algorithm specific configuration
Name Type Default Optional Description

propertyDimension

Integer

`0`

yes

The dimension of the projected node properties. Maximum value is `embeddingDimension`.

featureProperties

List<String>

`[]`

yes

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

embeddingDimension

Integer

`n/a`

no

The dimension of the computed node embeddings. Minimum value is 1.

iterationWeights

List<Float>

`[0.0, 1.0, 1.0]`

yes

Contains a weight for each iteration. The weight controls how much the intermediate embedding from the iteration contributes to the final embedding.

normalizationStrength

Float

`0`

yes

The initial random vector for each node is scaled by its degree to the power of `normalizationStrength`.

relationshipWeightProperty

String

`null`

yes

The name of the relationship property used for weighted random projection

The number of iterations is equal to the length of `iterationWeights`, which must be at least one.

Table 40. Results
Name Type Description

nodeCount

Integer

The number of nodes processed.

nodePropertiesWritten

Integer

The number of node properties written.

createMillis

Integer

computeMillis

Integer

Milliseconds for running the algorithm.

writeMillis

Integer

Milliseconds for writing result data back to Neo4j.

configuration

Map

The configuration used for running the algorithm.

Memory estimation for FastRPExtended works similarly to FastRP, which we can see in the following example for the stream mode:

The following will estimate the memory requirements for FastRPExtended:
``````CALL gds.beta.fastRPExtended.stream.estimate('persons', {embeddingDimension: 128, propertyDimension: 64, featureProperties: ['p1', 'p2']})
YIELD nodeCount, relationshipCount, bytesMin, bytesMax, requiredMemory``````
Table 41. Results
nodeCount relationshipCount bytesMin bytesMax requiredMemory

7

18

11912

11912

"11912 Bytes"