neo4j cypher selecting a path whose nodes need to further match another pattern

前端 未结 1 406
暖寄归人
暖寄归人 2021-01-28 03:43

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 neo4

相关标签:
1条回答
  • 2021-01-28 04:27

    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)
    
    0 讨论(0)
提交回复
热议问题