neo4j cypher 选择其节点需要进一步匹配另一个模式的路径 [英] neo4j cypher selecting a path whose nodes need to further match another pattern

查看:10
本文介绍了neo4j cypher 选择其节点需要进一步匹配另一个模式的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含航班、站点和飞机的域.该站由飞行和飞行使用飞机连接.(这是我对 neo4j 发现的问题的扩展满足特定条件的所有路径) 我想找到所有满足连接时间要求但也使用具有 wifi 的飞机的有效路线.我在 neo4j 控制台中创建了一些示例数据.这是链接 console.neo4j.org/r/sdcixy.任何建议都会很棒.

I have a domain that contains flight, station and aircraft. The station are connected by flight and flight use aircraft. (this is an expansion of the problem that I have on neo4j finding all paths that meets a certain criteria) I want to find all the valid routes that meets the connection time requirement but also use aircraft that has wifi. I have create some sample data in the neo4j console. Here is the link console.neo4j.org/r/sdcixy. Any suggestion will be great.

推荐答案

第一步是获取所有飞行节点连接到属性wifi"等于 1 的 Aircraft 节点的路径.这一步由子句 1-4.第 5 条将合格路径上的飞行节点传递到下一个Where"第6节过滤掉那些连接不满足条件的路由.最后一个子句返回有效航线上的航班名称.

The first step is to get paths with all flight nodes connected to Aircraft nodes with the property "wifi" equal 1. This step is implemented by the clauses 1-4. The clause 5 passes the flight nodes on the qualified paths to the next "Where" The clause 6 filter out those routes whose connections do not satisfy the condition. The last clause returns flight names on the valid routes.

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)

这篇关于neo4j cypher 选择其节点需要进一步匹配另一个模式的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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