Created
March 29, 2017 08:21
-
-
Save jvilledieu/93e5c1fc4140fdf588b0fe049030d14f to your computer and use it in GitHub Desktop.
Supply chain management (https://github.com/neo4j-examples/graphgists/blob/master/retail/SupplyChainManagement.adoc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE (:BillOfMaterial { name: "BoM", cost: 500}) | |
FOREACH (r IN range(0,10)| | |
CREATE (:Retailer { name:"Retailer" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: 1})) | |
FOREACH (r IN range(0,1)| | |
CREATE (:Wholesaler { name:"Wholesaler" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
; | |
CREATE (:Product { name: "ProductA", lat: tan(rand())*100, long: tan(rand())*100, co2: 200, cost: 100, time: 0 }) | |
FOREACH (r IN range(0,2)| | |
CREATE (:Supplier { name:"SupplierA" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,1)| | |
CREATE (:Supplier { name:"SupplierB" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,5)| | |
CREATE (:RawSupplier{ name:"RawSupplierA" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,5)| | |
CREATE (:RawSupplier{ name:"RawSupplierB" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})); | |
CREATE (:Product { name: "ProductB", lat: tan(rand())*100, long: tan(rand())*100, co2: 200, cost: 100, time: 0 }) | |
FOREACH (r IN range(0,2)| | |
CREATE (:Supplier { name:"SupplierC" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,1)| | |
CREATE (:Supplier { name:"SupplierD" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,5)| | |
CREATE (:RawSupplier{ name:"RawSupplierC" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})) | |
FOREACH (r IN range(0,5)| | |
CREATE (:RawSupplier{ name:"RawSupplierD" + r, cost: round(exp(rand()*3)+20), co2: round(exp(rand()*8)+250), lat: tan(rand())*100, long: tan(rand())*100, time: round(rand()*5)})); | |
MATCH (sa:Supplier), (p:Product), (bom:BillOfMaterial), (w:Wholesaler), (r:Retailer) | |
WHERE sa.name CONTAINS "SupplierA" AND p.name CONTAINS "ProductA" | |
CREATE UNIQUE (sa)-[:DELIVER]->(p)-[:INCLUDES]->(bom)-[:DELIVER]->(w)-[:DELIVER]->(r) | |
WITH p, sa | |
MATCH (sb:Supplier) | |
WHERE sb.name CONTAINS "SupplierB" | |
CREATE UNIQUE (sb)-[:DELIVER]->(p) | |
WITH sb, sa | |
MATCH (ra:RawSupplier), (rb:RawSupplier) | |
WHERE ra.name CONTAINS "RawSupplierA" AND rb.name CONTAINS "RawSupplierB" | |
CREATE UNIQUE (ra)-[:DELIVER]->(sa) | |
CREATE UNIQUE (rb)-[:DELIVER]->(sb); | |
MATCH (sc:Supplier), (p:Product), (bom:BillOfMaterial) | |
WHERE sc.name CONTAINS "SupplierC" AND p.name CONTAINS "ProductB" | |
CREATE UNIQUE (sc)-[:DELIVER]->(p)-[:INCLUDES]->(bom) | |
WITH p, sc | |
MATCH (sd:Supplier) | |
WHERE sd.name CONTAINS "SupplierD" | |
CREATE UNIQUE (sd)-[:DELIVER]->(p) | |
WITH sd, sc | |
MATCH (rc:RawSupplier), (rd:RawSupplier) | |
WHERE rc.name CONTAINS "RawSupplierC" AND rd.name CONTAINS "RawSupplierD" | |
CREATE UNIQUE (rc)-[:DELIVER]->(sc) | |
CREATE UNIQUE (rd)-[:DELIVER]->(sd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment