我打算将我的整个图(包括具有关系的节点和"独立"节点(导出到 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]
的关系深度,但没有帮助。
使用单个查询导出数据的正确方法是什么?
我会在您的情况下尝试以下方法...
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 跳。通过这种方式,我们删除了导出重复项并加快了导出速度。