Pass graph property names to gephi using apoc.gephi.add()

1.2k views Asked by At

I am streaming graphs from neo4j to Gephi using the apoc.gephi.add(). The method only passes one property of the node as a node label in Gephi. Which is not only desired node label I want. Is there a way to transfer other property as a node label to Gephi?

For example, My query is as below:

MATCH p=(a:Artist)-[r:LOVES]->(b:Artist) WITH p LIMIT 5 
call apoc.gephi.add('http://localhost:8080','workspace2', p) yield nodes, relationships, time
return nodes, relationships, time

In the above query, it only shows the names of the artists.

enter image description here

The above nodes has other properties like type, year_of_work etc. I want to display the other properties too in the node in Gehi. The apoc method only pass one property as node label. Following is the Node table in Gephi.

enter image description here

So is there a way to pass other properties? Is there any other way to stream a graph in Gephi from neo4j with the desired behavior?

2

There are 2 answers

1
Bruno Peres On

All examples in the APOC Procedure docs show the paths being collected before the apoc.gephi.add call. So try it:

MATCH p=(a:Artist)-[r:LOVES]->(b:Artist)
WITH p LIMIT 5 
WITH collect(p) AS ps
call apoc.gephi.add('http://localhost:8080','workspace2', ps) yield nodes, relationships, time
return nodes, relationships, time
0
Tomaž Bratanič On

This functionality was just recently added. You can use:

MATCH p=(a:Artist)-[r:LOVES]->(b:Artist) WITH p LIMIT 5 
call apoc.gephi.add('http://localhost:8080','workspace2',p,'weight',['type', 'year_of_work']) yield nodes, relationships, time
return nodes, relationships, time

Where fourth parameter can be used to export weight, and fifth parameter as an array of all the properties you want to export from both nodes and relationships. Check documentation for more.