Giter VIP home page Giter VIP logo

ukrailway's Introduction

UK Railway Graph

UK railway data extracted from publicly available datasets (see Rail Delivery Group page). It works as a good dataset for learning how Cypher's quantified path patterns work.

Diagram of sample data

How to load the dataset

Run the Cypher in cypher/import.cypher against your Neo4j instance using Browser (you will need to remove the :auto commands if you want to run in cypher-shell). Note that the node and relationship counts will exceed the Aura free tier allowances.

Try it out with a query like this one:

MATCH (dmk:Station {name: 'Denmark Hill'})<-[:CALLS_AT]-(l1a:CallingPoint)
        (()-[:NEXT]->(n) 
          WHERE NOT EXISTS { (n)-[:CALLS_AT]->(:Station:LondonGroup) })+
        (l1b)-[:CALLS_AT]->(x:Station)<-[:CALLS_AT]-(l2a:CallingPoint)
        (()-[:NEXT]->(m)
          WHERE NOT EXISTS { (m)-[:CALLS_AT]->(:Station:LondonGroup) })+
        (l2b)-[:CALLS_AT]->(gtw:Station {name: 'Gatwick Airport'})
MATCH (l1a)-[:HAS]->(s1:Stop)-[:NEXT]->+(s2)<-[:HAS]-(l1b)
        WHERE time('09:30') < s1.departs < time('10:00')
MATCH (l2a)-[:HAS]->(s3:Stop)-[:NEXT]->+(s4)<-[:HAS]-(l2b)
        WHERE s2.arrives < s3.departs < s2.arrives + duration('PT15M')
RETURN s1.departs AS leg1Departs, s2.arrives AS leg1Arrives, x.name AS changeAt,
        s3.departs AS leg2Departs, s4.arrives AS leg2Arrive,
        duration.between(s1.departs, s4.arrives).minutes AS journeyTime
ORDER BY leg2Arrive LIMIT 5

All being well, it should return the following results:

╒═══════════╤═══════════╤══════════════════╤═══════════╤═══════════╤═══════════╕
│leg1Departs│leg1Arrives│changeAt          │leg2Departs│leg2Arrive │journeyTime│
╞═══════════╪═══════════╪══════════════════╪═══════════╪═══════════╪═══════════╡
│"09:37:00Z"│"09:50:00Z"│"Clapham Junction"│"09:53:00Z"│"10:19:00Z"│42         │
├───────────┼───────────┼──────────────────┼───────────┼───────────┼───────────┤
│"09:37:00Z"│"09:50:00Z"│"Clapham Junction"│"10:01:00Z"│"10:25:00Z"│48         │
├───────────┼───────────┼──────────────────┼───────────┼───────────┼───────────┤
│"09:52:00Z"│"10:05:00Z"│"Clapham Junction"│"10:12:00Z"│"10:38:00Z"│46         │
└───────────┴───────────┴──────────────────┴───────────┴───────────┴───────────┘

ukrailway's People

Contributors

dogofbrian avatar

Stargazers

Christophe Willemsen avatar Michael Simons avatar  avatar

Watchers

 avatar

Forkers

michael-simons

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.