'Convert bipartite graph to monopartite for community detection with GDS library
I'm trying to register a graph using gds.graph.create. The source graph contains two node classes connected by one relationship type. I would like the in-memory graph to have only a single node type so I can perform community detection. Here is what I have so far:
CALL gds.graph.create(
'userDataMono',
'MATCH (a) WHERE a:User OR a:Dataset RETURN id(a) as id',
'MATCH (a:User)-[r:GRANTED_ACCESS]-(b:Dataset) RETURN id(a) as from, id(b) as to'
)
YIELD graphName AS graph, nodeProjection, nodeCount AS nodes, relationshipCount AS rels
If I run the node query by itself, I get the expected list of node id's for both classes but if I run the full query as written above I get:
Failed to invoke procedure `gds.graph.create`: Caused by:
java.lang.IllegalArgumentException: Invalid node projection, one or more labels not
found: 'MATCH (a) WHERE a:User OR a:Dataset RETURN id(a) as id'
How do I correctly register this graph for analysis?
Neo4j 4.3.5 and GDS Library 1.7.1
Solution 1:[1]
You are using native projection procedure and are using Cypher Projection syntax.
You could use native Projection syntax as following:
CALL gds.graph.create(
'userDataMono',
['User', 'Dataset'],
'GRANTED_ACCESS'
)
YIELD graphName AS graph, nodeProjection, nodeCount AS nodes, relationshipCount AS rels
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tomaž BrataniÄ |
