connecteddata
play

ConnectedData @ian S robinson ian@neotechnology.com Neo4j - PowerPoint PPT Presentation

New Opportuni-es for ConnectedData @ian S robinson ian@neotechnology.com Neo4j Graph Database complexity = f(size, variable structure, connectedness) How Do Graphs Help


  1. New ¡Opportuni-es ¡for ¡ ConnectedData ¡ @ian S robinson ¡ ian@neotechnology.com ¡ ¡

  2. Neo4j ¡Graph ¡Database ¡

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

  4. How ¡Do ¡Graphs ¡Help ¡ • Represent ¡and ¡navigate ¡a ¡variably-­‑structured ¡ domain ¡ • Understand ¡which ¡things ¡are ¡connected, ¡how, ¡ and ¡with ¡what ¡strength, ¡weight ¡or ¡quality ¡

  5. Variable ¡Structure ¡ • Rela-onships ¡provide ¡structure ¡ • Importantly, ¡they ¡are ¡defined ¡with ¡regard ¡to ¡ node ¡ instances , ¡not ¡ classes ¡of ¡nodes ¡

  6. Connectedness ¡ Rela%onship ¡Names ¡ • Seman-cs ¡first-­‑class ¡element ¡in ¡data ¡model ¡ Rela%onship ¡Proper%es ¡ • Describe ¡weight, ¡strength ¡or ¡quality ¡of ¡a ¡ rela-onship ¡

  7. Making ¡Connec-ons ¡

  8. Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

  9. Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

  10. Triadic ¡Closure ¡– ¡Closing ¡Triangles ¡

  11. Recommending ¡New ¡Connec-ons ¡

  12. Immediate ¡Friendships ¡

  13. Means ¡and ¡Mo-ve ¡

  14. Recommenda-on ¡

  15. Recommend ¡New ¡Connec-ons ¡ 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

  16. 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

  17. Find ¡Terry’s ¡Friends’ ¡Friends ¡ MATCH (user:User{name:'Terry'}) -[:FRIEND*2]- -[:FRIEND*2]- ( (other:User other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

  18. Find ¡Terry’s ¡Friends’ ¡Friends ¡ MATCH ( MATCH (user:User user:User{name:'Terry name:'Terry'}) '}) -[:FRIEND*2]- -[:FRIEND*2]- ( (other:User other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC

  19. …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

  20. 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

  21. Return ¡The ¡Results ¡ MATCH (user:User{name:'Terry'}) -[:FRIEND*2]- (other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN RETURN other.name other.name AS name, AS name, COUNT(other) AS score COUNT(other) AS score ORDER BY score DESC ORDER BY score DESC

  22. Taking ¡Account ¡of ¡Friendship ¡Strength ¡ MATCH (user:User{name:'Terry'}) -[ -[rels:FRIEND rels:FRIEND*2]- *2]- (other:User) WHERE ALL(r IN rels WHERE ALL(r IN 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

  23. Nowhere ¡To ¡Hide ¡

  24. First-­‑Party ¡Fraud ¡ • Fraudsters ¡apply ¡for ¡credit ¡ – No ¡inten-on ¡of ¡repaying ¡ • Appear ¡normal ¡un-l ¡they ¡“burst ¡out” ¡ – Clear ¡out ¡accounts ¡ • Fraud ¡ring ¡ – Share ¡bits ¡of ¡iden-ty ¡(NI, ¡address, ¡telephone) ¡ – Coordinated ¡“burst ¡out” ¡

  25. Fraud ¡Ring ¡

  26. Query ¡ • Create ¡new ¡applicant ¡ ¡ • Connect ¡applicant ¡to ¡iden-ty ¡info ¡ – Reuse ¡exis-ng ¡iden-fy ¡info ¡where ¡possible ¡ Then ¡ • Select ¡applicant’s ¡iden-ty ¡info ¡ • Crawl ¡surrounding ¡graph ¡ – Look ¡for ¡expansive ¡clusters ¡of ¡account ¡holders ¡

  27. Path ¡Calcula-ons ¡

  28. Problem ¡ • Increase ¡in ¡parcel ¡traffic ¡ – Amazon, ¡eBay ¡ – Current ¡infrastructure ¡can’t ¡cope ¡ • Calculate ¡op-mal ¡route ¡ – Under ¡20ms ¡ – Routes ¡vary ¡over ¡-me ¡ • Numbers: ¡ – 2000-­‑3000 ¡parcels ¡per ¡second ¡ – 25 ¡na-onal ¡parcel ¡centres, ¡2 ¡million ¡postcodes, ¡30 ¡ million ¡address ¡

  29. Period ¡1 ¡

  30. Period ¡2 ¡

  31. Period ¡3 ¡

  32. The ¡Full ¡Graph ¡

  33. Steps ¡1 ¡and ¡2 ¡

  34. Find ¡Start ¡and ¡End ¡ MATCH (s:Location {name:{startLocation}}), (e:Location {name:{endLocation}})

  35. Calculate ¡Up ¡Leg ¡ MATCH upLeg = (s)<-[:DELIVERY_ROUTE*1..2]-(db1) WHERE all(r in relationships(upLeg) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd})

  36. Path ¡From ¡Start ¡to ¡a ¡Delivery ¡Base ¡ MATCH MATCH upLeg upLeg = (s)<-[:DELIVERY_ROUTE*1..2]-(db1) = (s)<-[:DELIVERY_ROUTE*1..2]-(db1) WHERE all(r in relationships(upLeg) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd})

  37. Filter ¡Rela-onships ¡by ¡Period ¡ MATCH upLeg = (s)<-[:DELIVERY_ROUTE*1..2]-(db1) WHERE all(r in relationships( WHERE all(r in relationships(upLeg upLeg) WHERE WHERE r.start_date r.start_date <= { <= {intervalStart intervalStart} AND AND r.end_date r.end_date >= { >= {intervalEnd intervalEnd}) })

  38. Calculate ¡Down ¡ Path ¡ 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})

  39. Step ¡3 ¡

  40. Find ¡Routes ¡Between ¡Delivery ¡Bases ¡ 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})

  41. Paths ¡Between ¡Delivery ¡Bases ¡ WITH db1, db2, upLeg, downLeg MATCH MATCH topRoute topRoute = = (db1)<-[:CONNECTED_TO]-() (db1)<-[:CONNECTED_TO]-() -[:CONNECTED_TO*1..3]-(db2) -[:CONNECTED_TO*1..3]-(db2) WHERE all(r in relationships(topRoute) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd})

  42. Filtered ¡by ¡Period ¡ WITH db1, db2, upLeg, downLeg MATCH topRoute = (db1)<-[:CONNECTED_TO]-() -[:CONNECTED_TO*1..3]-(db2) WHERE all(r in relationships( WHERE all(r in relationships(topRoute topRoute) WHERE r.start_date WHERE r.start_date <= { <= {intervalStart intervalStart} AND AND r.end_date r.end_date >= { >= {intervalEnd intervalEnd}) })

  43. Calculate ¡Shortest ¡Route ¡Between ¡ Delivery ¡Bases ¡ 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

  44. Calculate ¡Shortest ¡ Path ¡Between ¡ Delivery ¡Bases ¡ WITH upLeg, downLeg, topRoute, reduce ( reduce ( weight=0, weight=0, r in relationships( r in relationships(topRoute topRoute) | ) | weight+r.cost weight+r.cost) AS score ) AS score ORDER BY score ASC ORDER BY score ASC LIMIT 1 LIMIT 1 RETURN (nodes(upLeg) + tail(nodes(topRoute)) + tail(nodes(downLeg))) AS route

  45. 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

  46. Online ¡Training ¡ hgp://www.neo4j.org/learn/online_course ¡

  47. Graph ¡Gists ¡ hgps://github.com/neo4j-­‑contrib/graphgist/wiki ¡

  48. graphdatabases.com ¡ of Neo Technology Compliments Graph h Databases Ian Robinson, Jim Webber & Emil Eifrem

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend