Download - Neo4j a bit of math and magic
![Page 1: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/1.jpg)
N E O 4 JA L I T T L E B I T O F M A T H A N D M A G I C
![Page 2: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/2.jpg)
G R A P H S A R E E V E R Y W H E R E !
![Page 3: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/3.jpg)
O T H E R Q U E S T I O N S
• What film should I see tonight?
• Where should I have a lunch?
• How can I get there?
• How can I get the cheapest tickets for a flight?
![Page 4: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/4.jpg)
U S U A L LY W E U S E R E L AT I O N S
![Page 5: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/5.jpg)
Relational DB
Graph
![Page 6: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/6.jpg)
G R A P H D ATA B A S E S
A LT E R N A T I V E I S
![Page 7: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/7.jpg)
G R A P H D ATA B A S E S
• Neo4j
• FlockDB
• AllegroGraph
• GraphDB
• InfiniteGraph
• OrientDB
![Page 8: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/8.jpg)
I S I T R E A L LY A H I P S T E R T H I N G ?
• Java
• Community/Enterprise edition
• ASID compliant, cluster support, runtime failover
• Used by many companies
![Page 9: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/9.jpg)
C Y P H E R
• It’s like SQL but for graphs
MATCH (user)-[:friend]->(follower) WHERE user.name IN ['Joe', 'John', 'Sara', 'Maria', 'Steve'] AND follower.name =~ ’S.*' LIMIT 5 RETURN user.name, follower.name
![Page 10: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/10.jpg)
O K , N E O 4 J I S F O R TA S K S W H E R E D ATA I S A G R A P H .( W H E R E Y O U H A V E A L O T O F J O I N S )
![Page 11: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/11.jpg)
Q U I C K S TA R T
• http://neo4j.com/download/
• bin/neo4j start
• locahost:7474
![Page 12: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/12.jpg)
S O M E E X A M P L E S
MATCH ()-[r:ACTED_IN]->() RETURN r
MATCH (gene:Person)-[:ACTED_IN]->(m), (other)-[:ACTED_IN]->(m) WHERE gene.name="Gene Hackman" RETURN DISTINCT other;
MATCH (a:Person)-[:ACTED_IN]->(m) RETURN a.name, count(m) ORDER BY count(m) DESC LIMIT 10;
MATCH (tom:Person)-[:ACTED_IN]->()<-[:ACTED_IN]-(a:Person) WHERE tom.name="Tom Hanks" AND a.born < tom.born RETURN a.name;
![Page 13: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/13.jpg)
B A C O N N U M B E R
![Page 14: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/14.jpg)
MATCH (kevin:Person { name:"Kevin Bacon" }),(al:Person { name:"Al Pacino" }), p =
shortestPath((kevin)-[*..15]-(al)) RETURN p
MATCH p=shortestPath((kevin:Person)-[r:ACTED_IN*]-(actor)) WHERE kevin.name='Kevin Bacon' AND actor.name='Al Pacino' RETURN length([m in nodes(p) WHERE m:Movie]) as BaconNumber, [m in nodes(p) WHERE m:Movie | m.title] as Movies, [a in nodes(p) WHERE a:Person | a.name][1..-1] as KnowsActors
![Page 15: Neo4j a bit of math and magic](https://reader033.vdocument.in/reader033/viewer/2022051516/55ca4c56bb61eb43578b462b/html5/thumbnails/15.jpg)
Q & A
Q&A