-
-
Save freeeve/6111309 to your computer and use it in GitHub Desktop.
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
= Bus line network and routing | |
== The setup | |
This is the bus network for one Bus line `21` with a number of bus stops. | |
//setup | |
//hide | |
[source,cypher] | |
---- | |
CREATE (s1913:Neo4jStop {key:1913,name:"La Défense (Grande Arche)",latitude:48.89200565400341,longitude:2.2369831238174327}) | |
CREATE (e2084:Neo4jStop {key:2084,name:"Charles de Gaulle-Etoile",latitude:48.87416474488983,longitude:2.29507256293689}) | |
CREATE (s1913)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2084) | |
CREATE (e2053:Neo4jStop {key:2053,name:"Auber",latitude:48.87260817994105,longitude:2.3297068164482293}) | |
CREATE (s2084)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2053) | |
CREATE (e1967:Neo4jStop {key:1967,name:"Châtelet-Les Halles",latitude:48.86146371055862,longitude:2.346844131603014}) | |
CREATE (s2053)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1967) | |
CREATE (e1956:Neo4jStop {key:1956,name:"Gare de Lyon",latitude:48.844804715128525,longitude:2.3738435712712422}) | |
CREATE (s1967)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1956) | |
CREATE (e1835:Neo4jStop {key:1835,name:"Nation",latitude:48.8484803444062,longitude:2.39676520957729}) | |
CREATE (s1956)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1835) | |
CREATE (e1631:Neo4jStop {key:1631,name:"Vincennes",latitude:48.84732387116057,longitude:2.433531596877892}) | |
CREATE (s1835)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1631) | |
CREATE (e1689:Neo4jStop {key:1689,name:"Val de Fontenay",latitude:48.853539865493715,longitude:2.4886196422410003}) | |
CREATE (s1631)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1689) | |
CREATE (e1837:Neo4jStop {key:1837,name:"Neuilly-Plaisance",latitude:48.853415709406356,longitude:2.5135425883128466}) | |
CREATE (s1689)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1837) | |
CREATE (e2010:Neo4jStop {key:2010,name:"Bry-sur-Marne",latitude:48.8445340667769,longitude:2.5265438463007914}) | |
CREATE (s1837)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e2010) | |
CREATE (e1652:Neo4jStop {key:1652,name:"Noisy-le-Grand (Mont d'Est)",latitude:48.84079514562774,longitude:2.548002629723796}) | |
CREATE (s2010)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1652) | |
CREATE (s1713:Neo4jStop {key:1713,name:"Rueil-Malmaison",latitude:48.88722206053287,longitude:2.170623204930391}) | |
CREATE (e1831:Neo4jStop {key:1831,name:"Nanterre-Ville",latitude:48.89532514729429,longitude:2.1958404738707524}) | |
CREATE (s1713)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1831) | |
CREATE (e1830:Neo4jStop {key:1830,name:"Nanterre-Université",latitude:48.90145806746532,longitude:2.215467319236829}) | |
CREATE (s1831)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1830) | |
CREATE (e1829:Neo4jStop {key:1829,name:"Nanterre-Préfecture",latitude:48.89565993203451,longitude:2.2231003280556174}) | |
CREATE (s1830)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1829) | |
CREATE (s1829)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1913) | |
CREATE (e1840:Neo4jStop {key:1840,name:"Noisy-Champs",latitude:48.8426611070816,longitude:2.578252451182644}) | |
CREATE (s1652)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1840) | |
CREATE (e1839:Neo4jStop {key:1839,name:"Noisiel",latitude:48.84348503430221,longitude:2.616614613852153}) | |
CREATE (s1840)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1839) | |
CREATE (e1859:Neo4jStop {key:1859,name:"Lognes",latitude:48.838922336696,longitude:2.633949874255556}) | |
CREATE (s1839)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1859) | |
CREATE (e1636:Neo4jStop {key:1636,name:"Torcy",latitude:48.83972842272958,longitude:2.655903115145281}) | |
CREATE (s1859)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1636) | |
CREATE (e2012:Neo4jStop {key:2012,name:"Bussy-Saint-Georges",latitude:48.8370461919234,longitude:2.7098841280452173}) | |
CREATE (s1636)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2012) | |
CREATE (e161468:Neo4jStop {key:161468,name:"Val d'europe",latitude:48.855087772415835,longitude:2.774926121592525}) | |
CREATE (s2012)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e161468) | |
CREATE (e1885:Neo4jStop {key:1885,name:"Marne-la-Vallée Chessy",latitude:48.871173167841604,longitude:2.7828140416090412}) | |
CREATE (s161468)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1885) | |
CREATE (s1670:Neo4jStop {key:1670,name:"Saint-Germain-en-Laye",latitude:48.89830860836054,longitude:2.09511210577148}) | |
CREATE (e1851:Neo4jStop {key:1851,name:"Le Vésinet-Le Pecq",latitude:48.89835089406469,longitude:2.121828925443024}) | |
CREATE (s1670)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1851) | |
CREATE (e1850:Neo4jStop {key:1850,name:"Le Vésinet-Centre",latitude:48.89009570633796,longitude:2.1343746143232596}) | |
CREATE (s1851)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1850) | |
CREATE (e1970:Neo4jStop {key:1970,name:"Chatou-Croissy",latitude:48.885142071685785,longitude:2.155625867018615}) | |
CREATE (s1850)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1970) | |
CREATE (s1970)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1713) | |
CREATE (e1943:Neo4jStop {key:1943,name:"Fontenay-sous-Bois",latitude:48.8434118592224,longitude:2.464815403274336}) | |
CREATE (s1631)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1943) | |
CREATE (e1838:Neo4jStop {key:1838,name:"Nogent-sur-Marne",latitude:48.83510877417377,longitude:2.4716839161590887}) | |
CREATE (s1943)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1838) | |
CREATE (e1904:Neo4jStop {key:1904,name:"Joinville-le-Pont",latitude:48.821069678359656,longitude:2.4638349563053548}) | |
CREATE (s1838)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1904) | |
CREATE (e1671:Neo4jStop {key:1671,name:"Saint-Maur Créteil",latitude:48.80641960896216,longitude:2.47204505094563}) | |
CREATE (s1904)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1671) | |
CREATE (e1848:Neo4jStop {key:1848,name:"Le Parc de Saint-Maur",latitude:48.80515416622947,longitude:2.4856075719006507}) | |
CREATE (s1671)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1848) | |
CREATE (e2024:Neo4jStop {key:2024,name:"Champigny",latitude:48.80703580209233,longitude:2.509901668386353}) | |
CREATE (s1848)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2024) | |
CREATE (e1919:Neo4jStop {key:1919,name:"La Varenne-Chennevières",latitude:48.7949153076683,longitude:2.5132215474075674}) | |
CREATE (s2024)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1919) | |
CREATE (e1680:Neo4jStop {key:1680,name:"Sucy Bonneuil",latitude:48.77105153303763,longitude:2.507511268345535}) | |
CREATE (s1919)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1680) | |
CREATE (e2074:Neo4jStop {key:2074,name:"Boissy-Saint-Léger",latitude:48.752988644666615,longitude:2.5052228459567494}) | |
CREATE (s1680)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2074) | |
CREATE (s48429:Neo4jStop {key:48429,name:"Cergy-Le-Haut",latitude:49.048547258734644,longitude:2.0120551690790514}) | |
CREATE (e2022:Neo4jStop {key:2022,name:"Cergy-Saint-Christophe",latitude:49.04954211817629,longitude:2.0350436480345913}) | |
CREATE (s48429)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2022) | |
CREATE (e2021:Neo4jStop {key:2021,name:"Cergy-Préfecture",latitude:49.03594383494343,longitude:2.0801437572429307}) | |
CREATE (s2022)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2021) | |
CREATE (e48433:Neo4jStop {key:48433,name:"Neuville-Université",latitude:49.014337292933675,longitude:2.0784342019585837}) | |
CREATE (s2021)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e48433) | |
CREATE (e1983:Neo4jStop {key:1983,name:"Conflans-Fin d'Oise",latitude:48.99071051507488,longitude:2.073609141668205}) | |
CREATE (s48433)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1983) | |
CREATE (e2039:Neo4jStop {key:2039,name:"Achères-Ville",latitude:48.970077176304514,longitude:2.0776181820083806}) | |
CREATE (s1983)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2039) | |
CREATE (e1878:Neo4jStop {key:1878,name:"Maisons-Laffitte",latitude:48.94604723230418,longitude:2.144251676642267}) | |
CREATE (s2039)-[:STOPS_STOPS {min_time:360000,max_time:360000,lineId:21}]->(e1878) | |
CREATE (e1643:Neo4jStop {key:1643,name:"Sartrouville",latitude:48.93751218318358,longitude:2.157311047020583}) | |
CREATE (s1878)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1643) | |
CREATE (e1894:Neo4jStop {key:1894,name:"Houilles Carrières-sur-Seine",latitude:48.920645595306866,longitude:2.1844117553489246}) | |
CREATE (s1643)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1894) | |
CREATE (s1894)-[:STOPS_STOPS {min_time:300000,max_time:300000,lineId:21}]->(e1829) | |
CREATE (s1689)-[:STOPS_STOPS {min_time:300000,max_time:300000,lineId:21}]->(e1652) | |
CREATE (s1801:Neo4jStop {key:1801,name:"Poissy",latitude:48.933164262405,longitude:2.041083510970564}) | |
CREATE (e2776542:Neo4jStop {key:2776542,name:"Acheres Grand Cormier",latitude:48.95518178055726,longitude:2.0925262190765865}) | |
CREATE (s1801)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2776542) | |
CREATE (s2776542)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1878) | |
CREATE (s2074)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1680) | |
CREATE (s1680)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1919) | |
CREATE (s1919)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e2024) | |
CREATE (s2024)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1848) | |
CREATE (s1848)-[:STOPS_STOPS {min_time:60000,max_time:60000,lineId:21}]->(e1671) | |
CREATE (s1671)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1904) | |
CREATE (s1904)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1838) | |
CREATE (s1838)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1943) | |
CREATE (s1943)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1631) | |
CREATE (s1631)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1835) | |
CREATE (s1835)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1956) | |
CREATE (s1956)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1967) | |
CREATE (s1967)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2053) | |
CREATE (s2053)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2084) | |
CREATE (s2084)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1913) | |
CREATE (s1913)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1829) | |
CREATE (s1829)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1830) | |
CREATE (s1830)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1831) | |
CREATE (s1831)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1713) | |
CREATE (s1713)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1970) | |
CREATE (s1970)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1850) | |
CREATE (s1850)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1851) | |
CREATE (s1851)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1670) | |
CREATE (s1652)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e2010) | |
CREATE (s2010)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1837) | |
CREATE (s1837)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1689) | |
CREATE (s1689)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1631) | |
CREATE (s1885)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e161468) | |
CREATE (s161468)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2012) | |
CREATE (s2012)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1636) | |
CREATE (s1636)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1859) | |
CREATE (s1859)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1839) | |
CREATE (s1839)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1840) | |
CREATE (s1840)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1652) | |
CREATE (s1829)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e1894) | |
CREATE (s1894)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1643) | |
CREATE (s1643)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e1878) | |
CREATE (s1878)-[:STOPS_STOPS {min_time:300000,max_time:300000,lineId:21}]->(e2776542) | |
CREATE (s2776542)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1801) | |
CREATE (s1652)-[:STOPS_STOPS {min_time:300000,max_time:300000,lineId:21}]->(e1689) | |
CREATE (s1878)-[:STOPS_STOPS {min_time:420000,max_time:420000,lineId:21}]->(e2039) | |
CREATE (s2039)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e1983) | |
CREATE (s1983)-[:STOPS_STOPS {min_time:180000,max_time:180000,lineId:21}]->(e48433) | |
CREATE (s48433)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2021) | |
CREATE (s2021)-[:STOPS_STOPS {min_time:240000,max_time:240000,lineId:21}]->(e2022) | |
CREATE (s2022)-[:STOPS_STOPS {min_time:120000,max_time:120000,lineId:21}]->(e48429) | |
---- | |
== Find the outer stops for line 21 | |
Here, we want to find what nodes have only one relationship in this line `21` | |
[source,cypher] | |
---- | |
MATCH (stop1)-[r]-(s2) | |
WHERE r.lineId?=21 | |
WITH count(r) AS count, stop1 | |
WHERE count = 1 | |
RETURN stop1 | |
---- | |
//table | |
== Find all the stops for Line `21` to create a map | |
Here, all the stops that make up the line should be found in order to create a map, using the lat/lon properties on the stop nodes. | |
[source,cypher] | |
---- | |
MATCH (stop1)-[r]->(stop2) | |
WHERE r.lineId?=21 | |
RETURN stop1, r, stop2 | |
---- | |
//table | |
== console | |
//console |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment