在 Neo4j 中可视化连接的组件 [英] Visualize connected components in Neo4j

查看:19
本文介绍了在 Neo4j 中可视化连接的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用下面的代码找到图中最高密集连接的组件:

I can find the highest densely connected component in the graph using the code below:

CALL algo.unionFind.stream('', ':pnHours', {})
YIELD nodeId,setId
// groupBy setId, storing all node ids of the same set id into a list
MATCH (node) where id(node) = nodeId
WITH setId, collect(node) as nodes
// order by the size of nodes list descending
ORDER BY size(nodes) DESC
LIMIT 1 // limiting to 3
RETURN nodes;

但它不能帮助我可视化最上面的密集连接组件(子图),因为它发出的输出图是不相交的节点.是否可以将密集连接的组件可视化.如果是,那么如何

But it does not help me visualize the topmost densely connected component (sub-graph) because the output graph it emits are disjoint nodes. Is it possible to visualize the densely connected component. If yes, then how

推荐答案

以下查询应返回最大的 pnHours 连接组件(即,具有最多节点).它只获取最大组件的路径.

The following query should return all the single-step paths in the largest pnHours-connected component (i.e., the one having the most nodes). It only gets the paths for the largest component.

CALL algo.unionFind.stream(null, 'pnHours', {}) YIELD nodeId, setId
WITH setId, COLLECT(nodeId) as nodeIds
ORDER BY SIZE(nodeIds) DESC
LIMIT 1
UNWIND nodeIds AS nodeId
MATCH path = (n)-[:pnHours]->()
WHERE ID(n) = nodeId
RETURN path

neo4j 浏览器的 Graph 可视化结果将显示组件中的所有节点它们之间的关系.

The neo4j browser's Graph visualization of the results will show all the nodes in the component and their relationships.

这篇关于在 Neo4j 中可视化连接的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆