I have a case of scenario that there are TOURIST who wants to travel and every country has VISA control and there is a path along countries so some of connections you are not allowed to visit that specific country. There are 3 types of VISA (A,B,C) and i want make a query that makes a single traversal and returns which tourists can go which countries with their VISA types. Each tourist can have variations of those 3 VISA types and it's mapped between edges of COUNTRY nodes as a property of a enum value like this :
NOT_ALLOWED_TO_PASS: 0
VISA_A: 1
VISA_B: 2
VISA_C: 4
VISA_AB: 3
VISA_AC: 5
VISA_BC: 6
VISA_ABC:7
I have 2 types of nodes and 2 types of relations;
node t > "TOURIST" which has t.name and id,
node c > "COUNTRY" which has c.name and id
relation r1 > "CAN_START" which has only id // tourist can start from it's linked nodes
relation r2 > "CAN_PASS" which has r.visa_type //enum that i explained above
t - [r:can_start]-c
c- [r:can_pass]-c
I've achieved this with implementing this query below:
Match (t:Tourist)-[r1:CAN_START]-(c1:Country)
match path= (c1:Country) -[CAN_PASS*] -(c2:Country)
where all(r2 in relationships(path)where r2.visa_type IN ["1","3","5","7"]) //this for visa_type A
return t.name as Tourist, c1.name+collect(c2.name) as CountryListWithTypeA
i can get my result with doing union etc but it traverses network 3 times.I want to get this 3 different results within a single traversal.
How can i do that ?