使用Neo4j/cypher json输出中的d3js绘制图形 [英] Drawing a graph using d3js from neo4j/cypher json output

查看:352
本文介绍了使用Neo4j/cypher json输出中的d3js绘制图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在单个密码查询中返回特定路径的不同节点和边缘.例如,使用电影图,下面的查询分别返回电影和演员,我想一起返回所有节点.使用路径p =(...),nodes(p)实际上返回成对的节点,而不管使用distinct.

Is it possible to return in a single cypher query distinct nodes and edges of a specific path. For instance, using the movies graph the query below return separately movies and actors, I'd like to return all nodes together. using path p = (...) and nodes(p) actually returns pairs of nodes regardless the use of distinct.

match(m:Movie {name:"Rain"})-(p:Person)return {nodes:collect(distinct {name:m.title}),actors:collect(distinct {name:a.name) }),链接:collect({源:m.title,目标:a.name})}

match (m:Movie {name: "Rain"}) -- (p:Person) return {nodes: collect(distinct {name: m.title}), actors: collect(distinct {name: a.name}), links: collect({source: m.title, target: a.name})}

预先感谢您的帮助, 皮埃尔

Thanks in advance for any help, Pierre

推荐答案

内部获得了一些帮助,所以我分享了答案.使用neo'j 2.1.5,可以使用展开功能. 查询后的查询一旦返回路径中不同节点和不同边缘的列表,便会返回-至少可以与我的示例一起使用:

Got some help internally, so I'm sharing the answer. With neo'j 2.1.5, one can use unwind. The query following query returns in once the list of distinct nodes and distinct edges in the path - at least it worked with my examples:

match path = (p:Person {Name: 'Rain'})-[]-(m:Movie) unwind nodes(path) as p unwind rels(path) as r
return {nodes: collect(distinct p), links: collect(DISTINCT {source: id(startNode(r)), target: id(endNode(r))})}

这篇关于使用Neo4j/cypher json输出中的d3js绘制图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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