Skip to content

Instantly share code, notes, and snippets.

View iamvarol's full-sized avatar
🎯
Focusing

Emre iamvarol

🎯
Focusing
View GitHub Profile
MATCH (t:Tournament)
WHERE t.name = "Roland Garros" and t.type = "wta"
WITH t
ORDER BY t.year
WITH COLLECT(t) AS tournaments
CALL apoc.nodes.link(tournaments, "NEXT_TOURNAMENT");
MATCH (t:Tournament)
WHERE t.name = "US Open" and t.type = "wta"
WITH t
CALL apoc.periodic.iterate("
LOAD CSV WITH HEADERS FROM 'https://raw.githubusercontent.com/iamvarol/blogposts/main/medium/tennis/data.csv' AS row
WITH row, split(row.score, ' ') AS matchSets
WITH *, size(matchSets) AS setSize,
row.tourney_name + '_' + row.tourney_year + '_' + 'WTA' AS tournament_id,
row.tourney_name + '_' + row.tourney_year + '_' + 'WTA' + '_' + row.match_num AS matchId
RETURN *
"
,
"
MATCH (source:Node {id: 'INET_N_856'}), (target:Node {id: 'NutsCons_1003'})
CALL gds.shortestPath.dijkstra.stream('routes-weighted', {
sourceNode: source,
targetNode: target,
relationshipWeightProperty: 'length_km'
})
YIELD index, sourceNode, targetNode, totalCost, nodeIds, costs, path
RETURN
index,
gds.util.asNode(sourceNode).id AS sourceNodeName,
CALL gds.graph.project(
'routes-weighted',
'Node',
'PIPE',
{
relationshipProperties: 'length_km'
}
)
CALL gds.louvain.stream('pipes')
YIELD nodeId, communityId
RETURN
communityId,
SIZE(COLLECT(gds.util.asNode(nodeId).id)) AS number_of_nodes,
COLLECT(gds.util.asNode(nodeId).id) AS ids,
COLLECT(gds.util.asNode(nodeId).country_code) AS country_codes
ORDER BY number_of_nodes DESC, communityId;
CALL gds.graph.project('betweennessPipes', 'Node', 'PIPE')
CALL gds.betweenness.stream('betweennessPipes')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).id AS id, round(score,2) as score
ORDER BY score DESC, id ASC
LIMIT 10
CALL gds.degree.stream('degreeCentralityPipes')
YIELD nodeId, score
RETURN gds.util.asNode(nodeId).id AS id, score AS degree
ORDER BY degree DESC, id ASC
LIMIT 10
CALL gds.graph.project(
'degreeCentralityPipes',
'Node',
{
PIPE: {
orientation: "UNDIRECTED"
}
}
)
MATCH (n:Node)<-[r:PIPE]-(:Node)
RETURN n.id AS id, n.country_code AS countryCode, round(n.pagerank,2) AS pagerank, round(sum(r.max_cap_M_m3_per_d),2) as maximumAnnualGasVolume
ORDER BY pagerank DESC, id ASC
LIMIT 10