Gds.beta.graph.create.subgraph doesn't copy relationships when nodes are filtered

What I tried like this:

  1. I made News--RootWord graph and added news_group property on News nodes by GDS Louvain.

  2. Project News--RootWord graph as 'news'.

  3. Create subgraph:

call gds.beta.graph.create.subgraph(

It created a subgraph of 285 nodes and 0 relations.

  1. So I exported the "news" graph into a new graph in the neo4j server:

call gds.graph.export('news', {dbName:'news'})

and then browse the news group of 740(one of Louvain result group ids):

match (n:News)-[:FROM_NEWS]->(r:RootWord) where n.news_group=740
return n, r

It displayed thousands relationships of "FROM_NEWS" within the nodes of the news_group(740).

Would it be a bug or am I doing something wrong when I creat subgraph in memory?


I think that the issue is that you aren't exporting RootWord in your subgraph projection, and there are no relationships between News nodes.

You'll want to modify your subgraph projection:

CALL gds.beta.graph.create.subgraph(
  'n:RootWord OR (n:News AND n.news_group=740)',
YIELD graphName, fromGraphName, nodeCount, relationshipCount

That should load the news and rootWord nodes as well as the relationships between them.

1 Like

Oh, definitely I missed that part. Alicia, thanks again.
Subgraph is really good tool, I think I will use it a lot.