This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (c:Country)-[:JOINED_AT]->(y:Year) | |
WITH y.value as year, apoc.coll.sort(collect(c.name)) as cs | |
WITH year, reduce(r = "", x IN cs | CASE WHEN r = "" THEN x ELSE (r + ", " + x) END) as desc, reduce(n = 0, x IN cs | n + 1) as num | |
WITH collect({ year: year, num: num, desc: desc }) as all | |
WITH all, reduce(s = 0, x IN all | s + x.num) as total | |
WITH apoc.coll.union(all, [{ year: "Total", num: total, desc: "" }]) as result | |
UNWIND result as item | |
RETURN item.year as year, item.num as countriesJoined, item.desc as countries | |
ORDER BY item.year |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MERGE (bkk:Airport { IATA: "BKK" }) | |
WITH ("https://en.wikipedia.org/wiki/List_of_Thai_Airways_destinations") as url, bkk | |
CALL apoc.load.html(url, { codes: "table.sortable tr[style!=\"background-color:#DDDDDD\"] td:eq(2)" }) YIELD value | |
WITH filter(code IN value.codes WHERE code.text <> "BKK") as outsideCodes, bkk | |
UNWIND outsideCodes as code | |
MERGE (a:Airport { IATA: code.text }) | |
MERGE (bkk)-[:TO]->(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH ("https://vbatushkov.bitbucket.io/cayman.json") as url | |
CALL apoc.load.json(url) YIELD value | |
WITH value.origins AS os, value.destinationsPerOrigin as ds | |
UNWIND os as origin | |
FOREACH (d IN ds[origin] | | |
MERGE (a:Airport { IATA: origin }) | |
MERGE (b:Airport { IATA: d }) | |
MERGE (a)-[:TO]->(b) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL algo.pageRank.stream('Airport', 'TO', { iterations:20, dampingFactor:0.85 }) | |
YIELD nodeId, score | |
RETURN algo.asNode(nodeId).IATA as IATA, score | |
ORDER BY score DESC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH path = (:Airport { IATA: "BKK" })-[:TO*1..3]->(to) | |
WHERE to.IATA = "CYB" OR to.IATA = "LYB" OR to.IATA = "GMC" | |
RETURN path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MERGE (j:Airport { IATA: "HND" }) | |
WITH ("https://en.wikipedia.org/wiki/List_of_Japan_Airlines_destinations") as url, j | |
CALL apoc.load.html(url, { codes: "table.sortable tr[style!=\"background-color:#ddd\"] td:eq(3)" }) YIELD value | |
WITH filter(code IN value.codes WHERE code.text <> "HND") as outsideCodes, j | |
UNWIND outsideCodes as code | |
MERGE (a:Airport { IATA: code.text }) | |
MERGE (j)-[:TO]->(a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL apoc.load.html("https://www.last.fm/music", { data: "a.music-more-tags-tag-inner-wrap, section.music-section:eq(0) a.music-featured-item-heading-link" }) YIELD value | |
UNWIND value.data as n | |
MERGE (g:Genre { url: n.attributes.href, name: apoc.text.capitalizeAll(n.text) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (g:Genre) | |
CALL apoc.load.html("https://last.fm" + g.url + "/artists", { data: "h3.big-artist-list-title a" }) YIELD value | |
UNWIND value.data as n | |
MERGE (b:Band { name: n.text }) | |
MERGE (b)-[:OF]->(g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (b:Band)-[:OF]->(g:Genre) | |
RETURN b.name, count(g) as genres | |
ORDER BY genres DESC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MATCH (g1:Genre)<-[:OF]-(b:Band)-[:OF]->(g2:Genre) | |
RETURN g1.name as genre_name, count(DISTINCT b) as num_of_bands | |
ORDER BY num_of_bands DESC |