Photo by Manasvita S on Unsplash

One Month Graph Challenge Results

Welcome word

How and why

Graph of Graphs

LOAD CSV WITH HEADERS FROM 'https://vbatushkov.bitbucket.io/results.csv' AS line FIELDTERMINATOR ';' 
MERGE (g:Graph { day: date({ year: 2019, month: 5, day: toInteger(line.id) }), topic: line.topic, read: toInteger(line.read), lines: toInteger(line.lines), nodes: toInteger(line.nodes), rels: toInteger(line.rels), build: line.build, algs: coalesce(line.algs, "") })
MATCH (g:Graph)
WITH g, split(g.build, ",") as builds, split(g.algs, ",") as algorithms
WITH g, builds, filter(x IN algorithms WHERE x <> "") as algs
FOREACH (x IN builds |
MERGE (b:Build { name: x })
MERGE (g)-[:CREATED_WITH]->(b)
)
FOREACH (x IN algs |
MERGE (a:Algorithm { name: x })
MERGE (g)-[:USE]->(a)
)
MATCH (g:Graph)
WITH sum(g.lines) as totalCypherLines, apoc.math.round(avg(g.lines), 1) as avgCypherLinesPerTopic, sum(g.nodes) as totalNodes, sum(g.rels) as totalRelationships, apoc.math.round(avg(g.read), 1) as avgMinutesToRead
RETURN avgMinutesToRead, avgCypherLinesPerTopic, totalCypherLines, totalNodes, totalRelationships
MATCH (g:Graph)
OPTIONAL MATCH (g)-[:USE]->(a:Algorithm)
WITH g, collect(a.name) as algorithms
MATCH (g)-[:CREATED_WITH]->(b:Build)
WITH g, algorithms, collect(b.name) as builds
RETURN g.topic as topic, g.read as read, g.lines as lines, algorithms, builds
ORDER BY read DESC, lines DESC
MATCH (:Graph)-[u:USE]->(a:Algorithm)
WITH a.name as name, count(u) as num
WITH collect({ name: name, num: num }) as algs
MATCH (:Graph)-[c:CREATED_WITH]->(b:Build)
WITH b.name as name, count(c) as num, algs
WITH collect({ name: name, num: num }) as builds, algs
WITH apoc.coll.union(algs, builds) as items
UNWIND items as item
RETURN item.name as name, item.num as num
ORDER BY item.num DESC

Experience

Neo4j

Timing

Data

Goals

Tools

Neo4j Community Edition 3.4

Notes

Calend.ru

Canva + Unsplash + Pexels + …

Medium

Gist

Conclusion

Feedback

P.S.

Engineering Technical Lead @ Agoda. Neo4j Featured Community Member. Certified Neo4j Professional. Articles brewed on web, hops and indie rock’n’roll.