我有一个包含航班,火车站和飞机的域名。该站通过飞行和飞行使用飞机连接。 (这是我neo4j finding all paths that meets a certain criteria问题的扩展。我想找到满足连接时间要求的所有有效路线,但也使用有wifi的飞机。我在neo4j控制台中创建了一些示例数据。这是链接console.neo4j.org/r/sdcixy。任何建议都会很棒。
答案 0 :(得分:1)
第一步是获得所有飞行节点连接到飞机节点的路径,其属性“wifi”等于1.此步骤由第1-4条实现。 第5节将合格路径上的飞行节点传递给下一个“Where” 第6节过滤掉那些连接不满足条件的路由。 最后一个子句返回有效路由上的航班名称。
1. Match p=stb:Station-[:Connect*]->flt:Flight-[:Connect*]->ste:Station, flt-[:Use]->ac:Aircraft
2. Where stb.name='ST_B' and ste.name='ST_E'
3. distinct p as path, collect(ac) as acs
4. Where all ( ac in acs where ac.wifi = 1)
5. With filter(x in nodes(path) where x:Flight ) as flts
6. Where all ( i in Range(0,length(flts)-2) Where flts[i].arrvTime < flts[i+1].dptrTime)
7. Return extract(flt in flts | flt.name)