linfo2172-databases/P4/queries.cyp

72 lines
1.8 KiB
Plaintext
Raw Normal View History

2024-05-15 09:20:34 +02:00
# 1
MATCH (k:Continent {name:"Europe"})-[e:Encompasses]->(c:Country)-[:Borders]->(:Country {name:"Greece"})
WHERE e.percentage <> "100.0"
2024-05-15 09:20:34 +02:00
RETURN DISTINCT c.name;
# 2 - VALID
MATCH (:Country {name:"China"})-[:Borders]->(c:Country)-[:Borders]->(c2:Country)-[:Borders]->(:Country {name:"China"})
WHERE c.name < c2.name
RETURN c.name, c2.name;
# 3 - VALID
2024-05-15 09:20:34 +02:00
MATCH (:Continent {name:"Europe"})-[:Encompasses {percentage:100.0}]->(c:Country)-[:Borders]->(:Country)<-[e:Encompasses]-(k:Continent)
WHERE k.name <> "Europe" OR e.percentage <> 100.0
2024-05-15 09:20:34 +02:00
RETURN DISTINCT c.name;
# 4 - VALID
2024-05-15 09:20:34 +02:00
MATCH (:Country {name:"Turkey"})-[:Borders *..2]->(c:Country)<-[:Encompasses]-(k:Continent {name:"Asia"})
WHERE c.name <> "Turkey"
2024-05-15 09:20:34 +02:00
RETURN DISTINCT c.name
ORDER BY c.name;
# 5 - VALID
MATCH (:Continent {name:"Europe"})-[:Encompasses {percentage: "100.0"}]->(c:Country)
WITH c, COUNT {(c)-[:Borders]->()} AS degree
RETURN c.name, degree
ORDER BY degree DESC;
# 6 - VALID
MATCH (c:Country)
WITH c, COUNT{(c)-[:Borders]->()} AS degree
RETURN c.name, degree
ORDER BY degree DESC
LIMIT 1;
# 7 - VALID
MATCH p=shortestPath((:Country {name:"Belgium"})-[:Borders *]->(:Country {name:"China"}))
RETURN p;
# 8 - VALID
2024-05-15 09:20:34 +02:00
MATCH p=shortestPath((:Country {name:"Belgium"})-[:Borders *]->(d:Country))
WHERE d.name <> "Belgium"
2024-05-15 09:20:34 +02:00
RETURN d.name
ORDER BY length(p) DESC
LIMIT 1
;
# 9 - VALID
MATCH (c:Country)-[:Borders]->(c1:Country)
MATCH (c:Country)-[:Borders]->(c2:Country)
MATCH (c:Country)-[:Borders]->(c3:Country)
MATCH (c1:Country)-[:Borders]->(c2:Country)-[:Borders]->(c3:Country)-[:Borders]->(c1:Country)
WITH c, COUNT {(c)-[:Borders]->()} AS degree
WHERE degree = 3
RETURN DISTINCT c.name;
# 10 - VALID
MATCH (:Continent {name:"Europe"})-[:Encompasses]->(c:Country)
WHERE NOT (c:Country)-[:Borders *1..3]->(:Country)<-[:Encompasses]-(:Continent {name:"Asia"})
RETURN c.name
ORDER BY c.name;