可视化Neo4j中的连接组件 [英] Visualize connected components in 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浏览器的图形可视化结果将显示组件中的所有节点及其的关系.
The neo4j browser's Graph visualization of the results will show all the nodes in the component and their relationships.
这篇关于可视化Neo4j中的连接组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!