Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 790
smm Avatar asked Sep 18 '17 14:09

smm


1 Answers

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.

like image 165
Tomaž Bratanič Avatar answered Nov 11 '22 18:11

Tomaž Bratanič