【问题标题】:Visualize Strongly Connected Components result using Cypher使用 Cypher 可视化强连通分量结果
【发布时间】:2016-12-05 09:50:21
【问题描述】:

我使用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

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

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

【问题讨论】:

  • 您的查询中有一些问题,除了它没有按照您的要求进行。 RETURN DISTINCT "node" as element, ... 将始终返回字符串“node”作为结果中element 列的值——这可能不是您想要的。此外,UNION 子句之后的子查询永远不会匹配任何内容,因为 mazerunner 只会将 strongly_connected_components 属性添加到节点。

标签: apache-spark neo4j cypher strongly-connected-graph neo4j-mazerunner


【解决方案1】:

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

注意:关闭浏览器的 AUTO-COMPLETE 功能(在结果窗格的右下角)以仅查看每个集群中节点之间的 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)的所有路径。

【讨论】:

    【解决方案2】:

    您可以使用以下方法查询特定 id:

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

    【讨论】:

    • 感谢您的回复,但是我想可视化所有集群,以及连接到该集群的节点(限制图形限制的结果)
    【解决方案3】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多