导出到 Gephi
安装插件
请务必先安装插件并在工作区中激活它(在“Layout”旁边有一个新的“Streaming”标签),右键点击“Master”→“start”启动服务器。
您可以提供您的工作区名称(您可能需要在开始流式传输之前对其进行重命名),否则它将默认为 workspace0
默认的 Gephi-URL 是 https://:8080,结果为 https://:8080/workspace0?operation=updateGraph
也可以通过将以下内容添加到 apoc.conf
中进行配置
apoc.conf
apoc.gephi.url=url
或
apoc.conf
apoc.gephi.<key>.url=url
可用过程
下表描述了可用过程
限定名称 | 类型 | 发布版本 |
---|---|---|
|
|
|
导出格式
传入数据中的所有节点和关系都被转换为独立的 Gephi 流式 JSON 片段,以 \r\n 分隔。\r\n
。
导出的 JSON 示例
{"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 不会渲染图数据,除非您也在有效载荷中提供了 x,y 坐标,因此过程会在 1000x1000 的网格内发送随机坐标。 颜色是根据标签组合和关系类型生成的,这两者也会作为 权重属性以数字(整数、浮点数)或字符串形式存储。如果权重属性无效或为 null,则将使用默认值 1.0。 |
示例
您可以将您的图导出为无权重网络。
以下导出
ACTED_IN
路径match 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
您可以通过指定关系的属性来将图导出为有权重网络,该属性保存了权重值。
以下导出关系类型上存在
weightproperty
属性的 ACTED_IN
路径MATCH path = (:Person)-[r:ACTED_IN]->(:Movie)
WHERE r.weightproperty IS NOT NULL
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
您还可以通过添加一个可选数组,其中包含您想要导出的属性名称,来随图导出节点和/或关系的其他属性。
以下导出
ACTED_IN
路径,但仅包含 birthYear
和 role
属性MATCH path = (:Person)-[r:ACTED_IN]->(:Movie)
WHERE r.weightproperty IS NOT NULL
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