This chapter explains how to create an anonymous graph for a single algorithm execution.
The typical workflow when using the GDS library is to create a graph and store it in the catalog. This is useful to minimize reads from Neo4j and to run an algorithm with various settings or several algorithms on the same graph projection.
However, if you want to quickly run a single algorithm, it can be convenient to use an anonymous projection.
The syntax is similar to the ordinary syntax for gds.graph.create
, described here.
It differs however in that relationship projections cannot have more than one property.
Moreover, the nodeProjection
and relationshipProjection
arguments are named and placed in the configuration map of the algorithm:
Anonymous native projection syntax.
CALL gds.<algo>.<mode>(
{
nodeProjection: String, List or Map,
relationshipProjection: String, List or Map,
nodeProperties: String, List or Map,
relationshipProperties: String, List or Map,
// algorithm and other create configuration
}
)
The following examples demonstrates creating an anonymous graph from Person
nodes and KNOWS
relationships.
CALL gds.<algo>.<mode>(
{
nodeProjection: 'Person',
relationshipProjection: 'KNOWS',
nodeProperties: 'age',
relationshipProperties: 'weight',
// algorithm and other create configuration
}
)
The above example can be an alternative to the calls below:
CALL gds.graph.create(
{
'new-graph-name',
'Person',
'KNOWS',
{
nodeProperties: 'age',
relationshipProperties: 'weight'
// other create configuration
}
}
);
CALL gds.<algo>.<mode>(
'new-graph-name',
{
// algorithm configuration
}
);
CALL gds.graph.drop('new-graph-name');
Similarly for Cypher projection, the explicit creation with gds.graph.create.cypher
can be inlined in an algorithm call using the keys nodeQuery
and relationshipQuery
.
Anonymous cypher projection syntax.
CALL gds.<algo>.<mode>(
{
nodeQuery: String,
relationshipQuery: String,
// algorithm and other create configuration
}
)