Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-27-2022 04:51 PM
Hi, I just found out that Neo4j has an option called "Connect result nodes" which shows connections between nodes matched in a query. I want to replicate it (to plot the graph with python), but I don't understand why I can't achieve it. I want to build an ego-network of a node, so when I match all the nodes I need, I also want to show the connections between them.
I found out an APOC procedure called "apoc.algo.cover()" which should do this job, but it just doesn't "work".
This is an esample without "Connect result nodes" check in Neo4J:
MATCH p=(node {name:'ERN1'})-[*1]-(othernodes)
with collect(othernodes) as otherNodesList,p
call apoc.algo.cover(otherNodesList) yield rel
return startNode(rel),rel,endNode(rel),p limit 20
As you can see, I used the procedure but I don't see connections between them. I used "limit 20" because we are talking about thousands of nodes, but the result is the same. I just see self connections, and that's ok, but it's not enough. This is the same query but with "Connect result nodes" checked in Neo4j Browser:
03-03-2022 08:28 AM
I think the problem is that you are using the apoc.algo.cover only with other nodes.
You should include the start node as well, otherwise the procedure doesn't return everything.
So, you could rewrite your query in this way:
MATCH p=(node {name:'ERN1'})-[*1]-(othernodes)
with collect(othernodes) as otherNodesList, node
call apoc.algo.cover(otherNodesList) yield rel
return startNode(rel),rel,endNode(rel), node limit 20
Anyway, I'm not 100% sure this is the solution, because i don't have your dataset.
In case my query doesn't work, can you provide a small sample dataset?
All the sessions of the conference are now available online