0

我打算将我的整个图(具有关系的节点和“独立”节点)导出到 Gephi 中。为了实现它,我当前执行了两个查询:

// export relationships
match path = (n)--() 
with collect(path) as paths
call apoc.gephi.add(null, 'workspace1', paths, '', ['attr1', 'attr2']) yield nodes, relationships, time
return nodes, relationships, time

// export independent nodes
match path = (p) 
where not (p)--()
with collect(path) as paths
call apoc.gephi.add(null, 'workspace1', paths, '', ['attr1', 'attr2']) yield nodes, relationships, time
return nodes, relationships, time

我试图用一个查询替换它们,例如:

match path = (n)-[*0..]-() 
with collect(path) as paths
call apoc.gephi.add(null, 'workspace1', paths, '', ['attr1', 'attr2']) yield nodes, relationships, time
return nodes, relationships, time

不幸的是,查询永远不会完成并且有效地 DoS-es Neo4j(导致 Neo4j 端的 CPU 和 RAM 消耗高,并使其无响应)。我也试图限制与的关系深度,[*0..10]但没有帮助。

使用单个查询导出数据的正确方法是什么?

4

1 回答 1

1

我会在你的情况下尝试以下...

match path = (n)-[*0..1]->() 
with collect(path) as paths
call apoc.gephi.add(null, 'workspace1', paths, '', ['attr1', 'attr2']) yield nodes, relationships, time
return nodes, relationships, time

所以我们添加了关系的方向并且限制为只有 1 跳。通过这种方式,我们删除了导出重复项并加快了导出速度。

于 2017-11-15T13:22:59.417 回答