Export to Gephi
Gephi has a streaming plugin, that can provide and accept JSON-graph-data in a streaming fashion. The export to Gephi procedure sends data to this end point.
Installing the plugin
Make sure to install the plugin first and activate it for your workspace (there is a new "Streaming"-tab besides "Layout"), right-click "Master"→"start" to start the server.
You can provide your workspace name (you might want to rename it before you start thes streaming), otherwise it defaults to workspace0
The default Gephi-URL is http://localhost:8080, resulting in http://localhost:8080/workspace0?operation=updateGraph
It can also be configured by adding the following to apoc.conf
:
apoc.gephi.url=url
or
apoc.gephi.<key>.url=url
Available Procedure
The table below describes the available procedure:
Qualified Name | Type | Release |
---|---|---|
|
|
Export Format
All nodes and relationships of the passed in data are converted into individual Gephi-Streaming JSON fragements, separated by \r\n. \r\n
.
{"an":{"123":{"TYPE":"Person:Actor","label":"Tom Hanks", x:333,y:222,r:0.1,g:0.3,b:0.5}}}\r\n
{"an":{"345":{"TYPE":"Movie","label":"Forrest Gump", x:234,y:122,r:0.2,g:0.2,b:0.7}}}\r\n
{"ae":{"3344":{"TYPE":"ACTED_IN","label":"Tom Hanks",source:"123",target:"345","directed":true,"weight":1.0,r:0.1,g:0.3,b:0.5}}}
Gephi doesn’t render the graph data unless you also provide x,y coordinates in the payload, so the procedures send random ones within a 1000x1000 grid. Colors are generated per label combination and relationship-type, both of which are also transferred as Weight properties are stored as a number (integer,float) or a string. If the weight property is invalid or null, a default value of 1.0 will be used. |
Examples
You can export your graph as an unweighted network.
ACTED_IN
pathsmatch path = (:Person)-[:ACTED_IN]->(:Movie)
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths) yield nodes, relationships, time
return nodes, relationships, time
You can export your graph as a weighted network, by specifying the property of a relationship, that holds the weight value.
ACTED_IN
paths where the weightproperty
property exists on the relationship typematch path = (:Person)-[r:ACTED_IN]->(:Movie) where exists r.weightproperty
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths, 'weightproperty') yield nodes, relationships, time
return nodes, relationships, time
You can also export with your graph other properties of your nodes and/or relationship by adding an optional array with the property names you want to export.
ACTED_IN
paths, but only includes the birthYear
and role
propertiesmatch path = (:Person)-[r:ACTED_IN]->(:Movie) where exists r.weightproperty
WITH path LIMIT 1000
with collect(path) as paths
call apoc.gephi.add(null,'workspace0', paths, 'weightproperty',['birthYear', 'role']) yield nodes, relationships, time
return nodes, relationships, time