使用 Cypher 可视化强连通分量结果

Visualize Strongly Connected Components result using Cypher

我已经使用 neo4j-mazerunner 来分析图表上的 strongly_connected_components 关系。该过程已经结束,现在我在我的节点上得到了 strongly_connected_components 属性。

我使用以下查询来获取不同节点的节点行:

MATCH (n) WHERE has(n.strongly_connected_components)
RETURN DISTINCT "node" as element, n.strongly_connected_components
AS strongly_connected_components
LIMIT 25 UNION ALL MATCH ()-[r]-()
WHERE has(r.strongly_connected_components)
RETURN DISTINCT "relationship" AS element, r.strongly_connected_components 
AS strongly_connected_components LIMIT 25

我不确定如何对图形进行密码查询以可视化生成的集群。

如有任何帮助,我们将不胜感激。

您可以使用以下方式查询特定 ID:

match (n2 {strongly_connected_components:NODE_ID_HERE})-[r:NEXT]->(n) return n,n2 LIMIT 50

我可能误解了这里的问题,但这会让你更全面地了解你的强连接节点:

MATCH (n) WHERE has(n.strongly_connected_components) MATCH (n)-[*]-() RETURN n

此查询应 return 25 个集群,您应该能够在浏览器中将每个集群可视化为强连接节点。查询假定 FOO 是在要求它生成 strongly_connected_components 值时指定给 neo4j-mazerunner 的关系。

注意:关闭浏览器的自动完成功能(位于结果窗格的右下角)以仅查看每个集群中节点之间的 FOO 关系:

MATCH p=(n1)-[:FOO]->()
RETURN n1.strongly_connected_components AS clusterId, COLLECT(p) AS paths
LIMIT 25;

由于neo4j-mazerunner 将相同的strongly_connected_components 值分配给同一集群中的所有节点,因此此查询只是聚合具有相同strongly_connected_components 值的所有路径(标识为clusterId).