Showing results for 
Search instead for 
Did you mean: 

Sending virtual nodes to Gephi for visualisation

Hi Folks,

I have a query which gives me some virtual nodes and relationships. BUt now I want to send this over to gephi using the apoc.gephi.add. Unfortunately, I can't figure out if this is possible with vNodes.

Here is my current query:
MATCH (a:Author)
WITH collect(distinct as countries
WITH [cName in countries | apoc.create.vNode(['Country'],{name:cName})] as countryNodes
WITH,'name') as countries
MATCH (a1:Author)-->(p:Paper)<--(a2:Author)
WITH AS countryName1, as countryName2, count(distinct p) as numCollabs, countries
WITH countries[countryName1] as country1, countries[countryName2] as country2, apoc.create.vRelationship(countries[countryName1], 'COLLABORATED_WITH', {numCollabs: numCollabs}, countries[countryName2]) as rels
RETURN country1, country2, rels limit 25

This works fine, but the examples in the documentation for gephi.add use a MATCH, but I can't seem to do that here.

Similarly, I can't even export the properties from Neo4j to csv because something like this doesn't work:

This just returns null (because the nodes are virtual I guess) even though RETURN country1 returns a correct looking JSON object I can't return individual properties.

Any ideas?


Graph Fellow

With Gephi you can pass, as a 3rd parameter, a list of entities.
So, in your case, you could execute after your query:

// previous query substituting RETURN with WITH...
WITH [rels, country1, country2] as data // list of virtual start node, virtual end node and virtual rel
CALL apoc.gephi.add(null, 'workspace1',data) 
YIELD nodes, relationships, format 

Regarding the properties, you're right, return null because is a virtual node.
To return your properties, you have to use the function, for example

In general, with virtual entities, there are some apoc functions to use instead of "classic" neo4j functions:

  • apoc.node.labels
  • apoc.rel.type
  • apoc.rel.endNode
  • apoc.rel.startNode

and some procedures:

  • apoc.create.setProperty
  • apoc.create.setProperties
  • apoc.create.setRelProperty
  • apoc.create.setRelProperties
Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.