Random graph generation
In certain use cases it is useful to generate random graphs, for example, for testing or benchmarking purposes. For that reason the Neo4j Graph Algorithm library comes with a set of builtin graph generators. The generator stores the resulting graph in the graph catalog. That graph can be used as input for any algorithm in the library.
This feature is in the beta tier. For more information on feature tiers, see API Tiers.
It is currently not possible to persist these graphs in Neo4j. Running an algorithm in write mode on a generated graph will lead to unexpected results. 
The graph generation is parameterized by three dimensions:

node count  the number of nodes in the generated graph

average degree  describes the average outdegree of the generated nodes

relationship distribution function  the probability distribution method used to connect generated nodes
1. Syntax
CALL gds.beta.graph.generate(graphName: String, nodeCount: Integer, averageDegree: Integer, {
relationshipDistribution: String,
relationshipProperty: Map
})
YIELD name, nodes, relationships, generateMillis, relationshipSeed, averageDegree, relationshipDistribution, relationshipProperty
Name  Type  Default  Optional  Description 


String 

no 
The name under which the generated graph is stored. 

Integer 

no 
The number of generated nodes. 

Integer 

no 
The average outdegree of generated nodes. 

Map 

yes 
Additional configuration, see below. 
Name  Type  Default  Optional  Description 


String 

yes 
The probability distribution method used to connect generated nodes. For more information see Relationship Distribution. 

Integer 

yes 
The seed used for generating relationships. 

Map 

yes 
Describes the method used to generate a relationship property. By default no relationship property is generated. For more information see Relationship Property. 

String 

yes 
The relationship aggregation method cf. Relationship Projection. 

String 

yes 
The method of orienting edges. Allowed values are NATURAL, REVERSE and UNDIRECTED. 

Boolean 

yes 
Whether to allow relationships with identical source and target node. 
Name  Type  Description 


String 
The name under which the stored graph was stored. 

Integer 
The number of nodes in the graph. 

Integer 
The number of relationships in the graph. 

Integer 
Milliseconds for generating the graph. 

Integer 
The seed used for generating relationships. 

Float 
The average out degree of the generated nodes. 

String 
The probability distribution method used to connect generated nodes. 

String 
The configuration of the generated relationship property. 
2. Relationship Distribution
The relationshipDistribution
parameter controls the statistical method used for the generation of new relationships.
Currently there are three supported methods:

UNIFORM
 Distributes the outgoing relationships evenly, i.e., every node has exactly the same out degree (equal to the average degree). The target nodes are selected randomly. 
RANDOM
 Distributes the outgoing relationships using a normal distribution with an average ofaverageDegree
and a standard deviation of2 * averageDegree
. The target nodes are selected randomly. 
POWER_LAW
 Distributes the incoming relationships using a power law distribution. The out degree is based on a normal distribution.
3. Relationship Seed
The relationshipSeed
parameter allows, to generate graphs with the same relationships, if they have no property.
Currently the relationshipProperty
is not seeded, therefore the generated graphs can differ in their property values.
Hence generated graphs based on the same relationshipSeed
are not identical.
4. Relationship Property
The graph generator is capable of generating a relationship property.
This can be controlled using the relationshipProperty
parameter which accepts the following parameters:
Name  Type  Default  Optional  Description 


String 
null 
no 
The name under which the property values are stored. 

String 
null 
no 
The method used to generate property values. 

Float 
0.0 
yes 
Minimal value of the generated property (only supported by 

Float 
1.0 
yes 
Maximum value of the generated property (only supported by 

Float 
null 
yes 
Fixed value assigned to every relationship (only supported by 
Currently, there are two supported methods to generate relationship properties:

FIXED
 Assigns a fixed value to every relationship. Thevalue
parameter must be set. 
RANDOM
 Assigns a random value between the lower (min
) and upper (max
) bound.
Was this page helpful?