Skip to content

Instantly share code, notes, and snippets.

View vladbatushkov's full-sized avatar
🥥
Sabai sabai

Vlad Batushkov vladbatushkov

🥥
Sabai sabai
View GitHub Profile
@vladbatushkov
vladbatushkov / PathFinding.cql
Created November 4, 2019 15:20
find a path
MATCH p=(a1:Airport { code: "BKK" })-[:FLIES_TO]->(a2:Airport { code: "ARN" })
RETURN p
@vladbatushkov
vladbatushkov / Flights-Workshop-Links.md
Last active November 4, 2019 17:14
Useful links of Neo4j Flights Workshop
@vladbatushkov
vladbatushkov / Org.cql
Last active November 3, 2019 10:55
Sample of graph
MATCH (n) DETACH DELETE n;
MERGE (org:Organization { name: "StarWars Company", taxid: 111222333 })
MERGE (d0:Department { name: "IT" })
MERGE (d1:Department { name: "Frontend" })
MERGE (d2:Department { name: "DevOps" })
MERGE (d3:Department { name: "Website" })
MERGE (luke:Person { name: "Luke Skywalker" })
MERGE (r2d2:Person { name: "R2D2" })
@vladbatushkov
vladbatushkov / water-planet-v1.js
Last active September 22, 2019 12:58
Example of animation - breathing of water planet
const [scaleValue] = useState(new Animated.Value(1))
const waterAnimation = () => {
Animated.sequence([
Animated.timing(scaleValue, { // 1
toValue: 1.2,
duration: 1500,
easing: Easing.linear
}),
Animated.timing(scaleValue, { // 2
@vladbatushkov
vladbatushkov / Community_Detection.cypher
Last active August 21, 2019 16:36
Community Detection in city
CALL algo.scc(
'MATCH (p:Person)-[:FROM]->(:City { name: "Bangkok" }) RETURN id(p) as id',
'MATCH (p1:Person)-[:OUT]->(:Call)<-[:IN]-(p2:Person) RETURN id(p1) as source, id(p2) as target',
{ write: true, writeProperty: 'communityId', graph:'cypher' })
YIELD communityCount
MATCH (p:Person)-[:FROM]->(:City { name: "Bangkok" })
WITH p.name as name, p.communityId as communityId
RETURN communityId, count(name) as total
ORDER BY total DESC
@vladbatushkov
vladbatushkov / Degree_Centrality.cypher
Last active August 18, 2019 14:34
Apply Degree Centrality vs calculate it Manualy
// algorithm
CALL algo.degree.stream("City", "CONNECT_WITH", { direction: "both", weightProperty: "calls" }) YIELD nodeId, score
RETURN algo.asNode(nodeId).name AS name, score
ORDER BY score DESC
// manual calculation
MATCH (c:City)-[cw:CONNECT_WITH]-(:City)
RETURN c.name as name, SUM(cw.calls) as score
ORDER BY score DESC
@vladbatushkov
vladbatushkov / External_and_Internal_calls.cypher
Last active August 18, 2019 15:21
Calls between cities and inside
// clean up
MATCH (:City)-[cw:CONNECT_WITH]-(:City)
DELETE cw
// external calls - total
MATCH (c1:City)<-[:FROM]-(:Person)-[]->(c:Call)<-[]-(:Person)-[:FROM]->(c2:City)
WHERE id(c1) > id(c2)
WITH c1.name as from, c2.name as to, count(c) as calls
RETURN sum(calls) as s
@vladbatushkov
vladbatushkov / Population.cypher
Created August 18, 2019 12:36
Set city population
MATCH (c:City)<-[:FROM]-(p:Person)
WITH c, count(p) as pop
SET c.population = pop
@vladbatushkov
vladbatushkov / Top_10_from_Bangkok.cypher
Created August 18, 2019 09:30
Top 10 persons with highest number of calls from Bangkok
MATCH (c:City { name: "Bangkok" })<-[:FROM]-(p1:Person)-[:OUT]->(cc:Call)<-[:IN]-(p2:Person)
RETURN p1.name, count(cc) as total
ORDER BY total DESC
LIMIT 10
@vladbatushkov
vladbatushkov / Calls_from_Bangkok.cypher
Created August 18, 2019 09:26
Total of calls from Bangkok
MATCH (c:City { name: "Bangkok" })<-[:FROM]-(p1:Person)-[:OUT]->(cc:Call)<-[:IN]-(p2:Person)
RETURN count(cc) as total
ORDER BY total DESC