New ¡Opportuni-es ¡for ¡ ConnectedData ¡
@ianSrobinson ¡ ian@neotechnology.com ¡ ¡
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
@ianSrobinson ¡ ian@neotechnology.com ¡ ¡
MATCH (user:User{name:'Terry'})
(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC
MATCH ( MATCH (user:User user:User{name:'Terry name:'Terry'}) '})
(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC
MATCH (user:User{name:'Terry'})
( (other:User
WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC
MATCH ( MATCH (user:User user:User{name:'Terry name:'Terry'}) '})
( (other:User
WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score ORDER BY score DESC
MATCH (user:User{name:'Terry'})
(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
MATCH (user:User{name:'Terry'})
(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN other.name AS name, COUNT(other) AS score COUNT(other) AS score ORDER BY score DESC
MATCH (user:User{name:'Terry'})
(other:User) WHERE NOT (user)-[:FRIEND]-(other) RETURN RETURN other.name
AS name, COUNT(other) AS score COUNT(other) AS score ORDER BY score DESC ORDER BY score DESC
MATCH (user:User{name:'Terry'})
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
– Amazon, ¡eBay ¡ – Current ¡infrastructure ¡can’t ¡cope ¡
– Under ¡20ms ¡ – Routes ¡vary ¡over ¡-me ¡
– 2000-‑3000 ¡parcels ¡per ¡second ¡ – 25 ¡na-onal ¡parcel ¡centres, ¡2 ¡million ¡postcodes, ¡30 ¡ million ¡address ¡
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})
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})
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}) })
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]-()
WHERE all(r in relationships(topRoute) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd})
WITH db1, db2, upLeg, downLeg MATCH MATCH topRoute topRoute = = (db1)<-[:CONNECTED_TO]-() (db1)<-[:CONNECTED_TO]-()
WHERE all(r in relationships(topRoute) WHERE r.start_date <= {intervalStart} AND r.end_date >= {intervalEnd})
WITH db1, db2, upLeg, downLeg MATCH topRoute = (db1)<-[:CONNECTED_TO]-()
WHERE all(r in relationships( WHERE all(r in relationships(topRoute topRoute) WHERE WHERE r.start_date r.start_date <= { <= {intervalStart intervalStart} AND AND r.end_date r.end_date >= { >= {intervalEnd 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
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
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
hgp://www.neo4j.org/learn/online_course ¡
hgps://github.com/neo4j-‑contrib/graphgist/wiki ¡
Ian Robinson, Jim Webber & Emil Eifrem
Compliments