简体   繁体   中英

cypher query composite relationship match

with a graph successfully matching

MATCH (a:A)-[x:X]-(b:B)-[y:Y]-(c:C) RETURN *

is it possible to return something like

(a:A)-[z:Z]-(c:C)

which has a 'new' relationship z (let's call it 'linked via a B') that does not exist in the graph database, and that in effect represents a collapsing of

-[x:X]-(b:B)-[y:Y]- 

to

-[z:Z]-

Note, that the relationship -[z:Z]- does not exist in the graph.

Possible? What would the cypher look like?

thanks

This is possible with virtual relationships via APOC Procedures :

MATCH (a:A)-[x:X]-(b:B)-[y:Y]-(c:C)
CALL apoc.create.vRelationship(a,'Z',{}, c) YIELD rel
RETURN a, rel, c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM