Let Me Graph That For You @ian S robinson - - PowerPoint PPT Presentation

let me graph that for you
SMART_READER_LITE
LIVE PREVIEW

Let Me Graph That For You @ian S robinson - - PowerPoint PPT Presentation

Let Me Graph That For You @ian S robinson ian@neotechnology.com @neo4j complexity = f(size, variable structure, connectedness) @neo4j Graphs Are Everywhere @neo4j Graph


slide-1
SLIDE 1

@neo4j ¡

Let ¡Me ¡Graph ¡That ¡For ¡You ¡

@ianSrobinson ¡ ian@neotechnology.com ¡ ¡

slide-2
SLIDE 2

@neo4j ¡

complexity = f(size, variable structure, connectedness) ¡

slide-3
SLIDE 3

@neo4j ¡

Graphs ¡Are ¡Everywhere ¡

slide-4
SLIDE 4

@neo4j ¡

  • Store ¡
  • Manage ¡
  • Query ¡

data ¡

Graph ¡Databases ¡

slide-5
SLIDE 5

@neo4j ¡

Neo4j ¡is ¡a ¡Graph ¡Database ¡

slide-6
SLIDE 6

@neo4j ¡

Labeled ¡Property ¡Graph ¡

slide-7
SLIDE 7

@neo4j ¡

Making ¡ConnecIons ¡

slide-8
SLIDE 8

@neo4j ¡

Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

slide-9
SLIDE 9

@neo4j ¡

Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

slide-10
SLIDE 10

@neo4j ¡

Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

slide-11
SLIDE 11

@neo4j ¡

Recommending ¡New ¡ConnecIons ¡

slide-12
SLIDE 12

@neo4j ¡

Immediate ¡Friendships ¡

slide-13
SLIDE 13

@neo4j ¡

Means ¡and ¡MoIve ¡

slide-14
SLIDE 14

@neo4j ¡

RecommendaIon ¡

slide-15
SLIDE 15

@neo4j ¡

Recommend ¡New ¡ConnecIons ¡

MATCH (user:User{name:'Terry'})

  • [:FRIEND*2]-

(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-16
SLIDE 16

@neo4j ¡

Find ¡Terry ¡

MATCH ( MATCH (user:User user:User{name:'Terry name:'Terry'}) '})

  • [:FRIEND*2]-

(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-17
SLIDE 17

@neo4j ¡

Find ¡Terry’s ¡Friends’ ¡Friends ¡

MATCH (user:User{name:'Terry'})

  • [:FRIEND*2]-
  • [:FRIEND*2]-

( (other:User

  • ther:User)

WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-18
SLIDE 18

@neo4j ¡

Find ¡Terry’s ¡Friends’ ¡Friends ¡

MATCH ( MATCH (user:User user:User{name:'Terry name:'Terry'}) '})

  • [:FRIEND*2]-
  • [:FRIEND*2]-

( (other:User

  • ther:User)

WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-19
SLIDE 19

@neo4j ¡

…Who ¡Terry ¡Doesn’t ¡Know ¡

MATCH (user:User{name:'Terry'})

  • [:FRIEND*2]-

(other:User) WHERE NOT (user)-[:FRIEND]-(other) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-20
SLIDE 20

@neo4j ¡

Count ¡Matches ¡Per ¡Person ¡

MATCH (user:User{name:'Terry'})

  • [:FRIEND*2]-

(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score COUNT(other) AS score ORDER BY score DESC

slide-21
SLIDE 21

@neo4j ¡

Return ¡The ¡Results ¡

MATCH (user:User{name:'Terry'})

  • [:FRIEND*2]-

(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN RETURN other.name

  • ther.name AS name,

AS name, COUNT(other) AS score COUNT(other) AS score ORDER BY score DESC ORDER BY score DESC

slide-22
SLIDE 22

@neo4j ¡

Taking ¡Account ¡of ¡Friendship ¡Strength ¡

MATCH (user:User{name:'Terry'})

  • [
  • [rels:FRIEND

rels:FRIEND*2]- *2]- (other:User) WHERE ALL(r IN WHERE ALL(r IN rels rels WHERE WHERE r.strength r.strength > 1) > 1) AND NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

slide-23
SLIDE 23

@neo4j ¡

Nowhere ¡To ¡Hide ¡

slide-24
SLIDE 24

@neo4j ¡

First-­‑Party ¡Fraud ¡

  • Fraudsters ¡apply ¡for ¡credit ¡

– No ¡intenIon ¡of ¡repaying ¡

  • Appear ¡normal ¡unIl ¡they ¡“burst ¡out” ¡

– Clear ¡out ¡accounts ¡

  • Fraud ¡ring ¡

– Share ¡bits ¡of ¡idenIty ¡(NI, ¡address, ¡telephone) ¡ – Coordinated ¡“burst ¡out” ¡

slide-25
SLIDE 25

@neo4j ¡

Fraud ¡Ring ¡

slide-26
SLIDE 26

@neo4j ¡

Query ¡

  • Create ¡new ¡applicant ¡ ¡
  • Connect ¡applicant ¡to ¡idenIty ¡info ¡

– Reuse ¡exisIng ¡idenIfy ¡info ¡where ¡possible ¡

Then ¡

  • Select ¡applicant’s ¡idenIty ¡info ¡
  • Crawl ¡surrounding ¡graph ¡

– Look ¡for ¡expansive ¡clusters ¡of ¡account ¡holders ¡

slide-27
SLIDE 27

@neo4j ¡

Path ¡CalculaIons ¡

slide-28
SLIDE 28

@neo4j ¡

Problem ¡

  • Increase ¡in ¡parcel ¡traffic ¡

– Amazon, ¡eBay ¡ – Current ¡infrastructure ¡can’t ¡cope ¡

  • Calculate ¡opImal ¡route ¡

– Under ¡40ms ¡ – Routes ¡vary ¡over ¡Ime ¡

  • Numbers: ¡

– 2000-­‑3000 ¡parcels ¡per ¡second ¡ – 25 ¡naIonal ¡parcel ¡centres, ¡2 ¡million ¡postcodes, ¡30 ¡ million ¡address ¡

slide-29
SLIDE 29

@neo4j ¡

Period ¡1 ¡

slide-30
SLIDE 30

@neo4j ¡

Period ¡2 ¡

slide-31
SLIDE 31

@neo4j ¡

Period ¡3 ¡

slide-32
SLIDE 32

@neo4j ¡

The ¡Full ¡Graph ¡

slide-33
SLIDE 33

@neo4j ¡

slide-34
SLIDE 34

@neo4j ¡

Steps ¡1 ¡and ¡2 ¡

slide-35
SLIDE 35

@neo4j ¡

Step ¡3 ¡

slide-36
SLIDE 36

@neo4j ¡

Paths ¡

MATCH path=(from{name:'X'})

  • [:CONNECTED_TO*1..4]->

(to{name:'Y'}) RETURN path AS shortestPath, reduce(weight=0, r in relationships(path) | weight + r.weight) AS total ORDER BY total ASC LIMIT 1

slide-37
SLIDE 37

@neo4j ¡

Match ¡Variable-­‑Length ¡Path ¡

MATCH path=(from{name:'X'})

  • [:CONNECTED_TO*1..4]->

(to{name:'Y'}) RETURN path AS shortestPath, reduce(weight=0, r in relationships(path) | weight + r.weight) AS total ORDER BY total ASC LIMIT 1

slide-38
SLIDE 38

@neo4j ¡

Calculate ¡Path ¡Weight ¡

MATCH path=(from{name:'X'})

  • [:CONNECTED_TO*1..4]->

(to{name:'Y'}) RETURN path AS shortestPath, reduce(weight=0, r in relationships(path) | weight + r.weight) AS total ORDER BY total ASC LIMIT 1

slide-39
SLIDE 39

@neo4j ¡

Return ¡Shortest ¡Weighted ¡Path ¡

MATCH path=(from{name:'X'})

  • [:CONNECTED_TO*1..4]->

(to{name:'Y'}) RETURN path AS shortestPath, reduce(weight=0, r in relationships(path) | weight + r.weight) AS total ORDER BY total ASC LIMIT 1

slide-40
SLIDE 40

@neo4j ¡

Full ¡Query ¡

MATCH (s:Location {name:{startLocation}}), (e:Location {name:{endLocation}}) MATCH upLeg = (s)<-[:DELIVERY_ROUTE*1..2]-(db1) WHERE all(r in relationships(upLeg) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd}) WITH e, upLeg, db1 MATCH downLeg = (db2)-[:DELIVERY_ROUTE*1..2]->(e) WHERE all(r in relationships(downLeg) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd}) WITH db1, db2, upLeg, downLeg MATCH topRoute = (db1)<-[:CONNECTED_TO]-()-[:CONNECTED_TO*1..3]-(db2) WHERE all(r in relationships(topRoute) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd}) WITH upLeg, downLeg, topRoute, reduce(weight=0, r in relationships(topRoute) | weight+r.cost) AS score ORDER BY score ASC LIMIT 1 RETURN (nodes(upLeg) + tail(nodes(topRoute)) + tail(nodes(downLeg))) AS route

slide-41
SLIDE 41

@neo4j ¡

neo4j.com/online_course ¡

slide-42
SLIDE 42

@neo4j ¡

Ian Robinson, Jim Webber & Emil Eifrem

Graph Databases h

Compliments
  • f Neo Technology

graphdatabases.com ¡

@ianSrobinson ¡ #neo4j ¡ ¡ ¡

Thank ¡you ¡