In order to customize the projected graph even more, you can use Cypher projection. It enables us to create relationships on the fly that will only be created in the projected graph and not in the Neo4j graph. The syntax to create the projected graph is quite similar to the native projected graph syntax, except that the configuration of nodes and relationships is done through a Cypher query:
CALL gds.graph.create.cypher(
graphName::STRING,
nodeQuery::STRING,
relationshipQuery::STRING,
configuration::MAP
)
The only constraints are as follows:
- nodeQuery must return a property named id, containing a node unique identifier.
- relationshipQuery must contain two properties, source and destination, indicating the source and destination node identifiers.
The equivalent of myProjectedGraph with Cypher projection would be the following:
CALL gds.graph.create.cypher(
"myProjectedCypherGraph",
"MATCH (u:User) RETURN id(u) as id",
"...