How to replicate "Connect result nodes" with cypher

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:

And there they are, connections between nodes. Why can't I achieve the same even if I use the procedure? What's wrong there?


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?