All Projects → IgorRozani → Public-Transport-SP-Graph-Database

IgorRozani / Public-Transport-SP-Graph-Database

Licence: MIT license
Metropolitan Transport Network from São Paulo mapped in a NoSQL graph database.

Projects that are alternatives of or similar to Public-Transport-SP-Graph-Database

NeoClient
🦉 Lightweight OGM for Neo4j which support transactions and BOLT protocol.
Stars: ✭ 21 (-16%)
Mutual labels:  neo4j, nosql, graph-database, cypher
Neo4j
Graphs for Everyone
Stars: ✭ 9,582 (+38228%)
Mutual labels:  neo4j, nosql, graph-database, cypher
Movies Python Bolt
Neo4j Movies Example application with Flask backend using the neo4j-python-driver
Stars: ✭ 197 (+688%)
Mutual labels:  neo4j, graph-database, cypher
seabolt
Neo4j Bolt Connector for C
Stars: ✭ 37 (+48%)
Mutual labels:  neo4j, graph-database, cypher
Movies Javascript Bolt
Neo4j Movies Example with webpack-in-browser app using the neo4j-javascript-driver
Stars: ✭ 123 (+392%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j 3d Force Graph
Experiments with Neo4j & 3d-force-graph https://github.com/vasturiano/3d-force-graph
Stars: ✭ 159 (+536%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j Etl
Data import from relational databases to Neo4j.
Stars: ✭ 165 (+560%)
Mutual labels:  neo4j, graph-database, cypher
Helicalinsight
Helical Insight software is world’s first Open Source Business Intelligence framework which helps you to make sense out of your data and make well informed decisions.
Stars: ✭ 214 (+756%)
Mutual labels:  neo4j, nosql, graph-database
R2d2 Cypher
Cypher support for the r2d2 connection pool
Stars: ✭ 8 (-68%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j Tableau
Neo4j Tableau Integration via WDC
Stars: ✭ 56 (+124%)
Mutual labels:  neo4j, graph-database, cypher
Movies Java Bolt
Neo4j Movies Example application with SparkJava backend using the neo4j-java-driver
Stars: ✭ 66 (+164%)
Mutual labels:  neo4j, graph-database, cypher
ml-models
Machine Learning Procedures and Functions for Neo4j
Stars: ✭ 63 (+152%)
Mutual labels:  neo4j, graph-database, cypher
Redisgraph
A graph database as a Redis module
Stars: ✭ 1,292 (+5068%)
Mutual labels:  nosql, graph-database, cypher
Neo4j Python Driver
Neo4j Bolt driver for Python
Stars: ✭ 607 (+2328%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j Graph Algorithms
Efficient Graph Algorithms for Neo4j
Stars: ✭ 713 (+2752%)
Mutual labels:  neo4j, graph-database, cypher
neo4j-faker
Use faker cypher functions to generate demo and test data with cypher
Stars: ✭ 30 (+20%)
Mutual labels:  neo4j, graph-database, cypher
angular-neo4j
Neo4j Bolt driver wrapper for Angular
Stars: ✭ 18 (-28%)
Mutual labels:  neo4j, graph-database, cypher
Reddit Detective
Play detective on Reddit: Discover political disinformation campaigns, secret influencers and more
Stars: ✭ 129 (+416%)
Mutual labels:  neo4j, graph-database
Neo4j Php Ogm
Neo4j Object Graph Mapper for PHP
Stars: ✭ 151 (+504%)
Mutual labels:  neo4j, graph-database
Neo4j Streams
Neo4j Kafka Integrations, Docs =>
Stars: ✭ 126 (+404%)
Mutual labels:  neo4j, graph-database

Public Transport SP - Graph Database

Metropolitan Transport Network from São Paulo, Brazil, mapped in a NoSQL graph database.

Read this in other languages: Português

You can read a more detailed explanation (in portuguese) in my medium: https://medium.com/@igorrozani/transporte-de-sp-em-um-banco-de-grafos-3ce17d4f1f41

Summary

Inspiration

Based in the metropolitan transport network map from São Paulo (image below), i mapped all the stations, terminals, lines and connections utilizing the database Neo4j and the language openCypher.

Map

Database structure

It was defined the following database model:

Database model

The nodes are:

  • BusTerminal - bus terminals. Example: São Bernardo;
  • Company - the company responsable by the transport line. Example: CPTM;
  • Line - the transport lines. Example: Yellow line;
  • MetroStation - the metro stations. Example: Paulista;
  • OrcaShuttleTerminal - Orca Shuttle terminals. Example: Jabaquara;
  • PointOfInterest - points of interest from the map. Example: Zoo;
  • TouristicTerminal - tourist terminal stations. Example: Paranapiacaba;
  • TrainStation - train stations. Example: Morumbi.

And the relationships are:

  • CONNECT - connection between stations and/or terminals;
  • HAS - relationship between Station/Terminal and the PointOfInterest;
  • INTEGRATION - integration between different types of stations and terminals;
  • OWN - relationship between the company and line, to represent that the company owns that line;
  • PART_OF - relationship between the station/terminal and line, to represent that the station/terminal is part of that line.

Required softwares

To run this project, it's necessary to install the Neo4j, you can download it here.

Examples

Create

Create a node

CREATE (:Line {name:'Emerald', number:9})

Create a relationship

MATCH (s1:TrainStation{name:'Poá'}),(s2:TrainStation{name:'Suzano'})
CREATE (s1)-[r:CONNECT{transport: 'train'}]->(s2)

Delete

Delete all database items

MATCH (n)-[r]-()
DELETE n,r

Queries

All database nodes

MATCH (n)
RETURN n

All stations/terminals from a line

MATCH (l:Line)-[:PART_OF]-(s)
RETURN l.name AS Line, collect(s.name) AS Stations

All stations with elevator

MATCH (s {hasElevator:true})
RETURN s

All station connections

MATCH ({name:'Luz'})-[:CONNECT]-(s)
Return s

All node connections of TouristicTerminal label

MATCH (s:TouristicTerminal)-[:CONNECT]-({name:'Luz'})
Return s

All lines from a company

MATCH (c:Company)-[:OWN]-(l:Line)
WITH c, l
ORDER BY l.number, l.name
WITH c, collect(CASE WHEN l.number IS NULL THEN l.name ELSE l.number + ' - ' + l.name END) as lines
RETURN c.name, lines
ORDER BY c.name

All relationship type sorted by alphabetical order

MATCH ()-[r]-()
WITH DISTINCT type(r) AS relationships
RETURN DISTINCT relationships
ORDER BY relationships

All nodes label sorted by alphabetical order

MATCH (n)
WITH DISTINCT labels(n) AS labels
UNWIND labels AS label
RETURN DISTINCT label
ORDER BY label

Quantity stations or terminals by line

MATCH (l:Line)-[:PART_OF]-(s)
WITH l, count(s) as qtd
RETURN l.name, qtd
ORDER BY l.name

Quantity of place with bike parking terminal or bike attaching post

MATCH (n)
WHERE n.hasBikeAttachingPost = true OR n.hasBikeParkingTerminal = true
RETURN n

All nodes that are in more than one line

MATCH (:Line)-[p:PART_OF]-(s)
WITH s, count(p) as qtd
WHERE qtd > 1
RETURN s.name, qtd
ORDER BY qtd DESC

Shortest path between stations, indepent of stations types

MATCH x = shortestPath((s1{name:"Grajaú"})-[:CONNECT*]-(s2{name:"Rio Grande da Serra"}))
RETURN EXTRACT(n IN NODES(x) | n.name) AS Directions

Shortest path between stations, only using train or metro

MATCH 
	(s1{name:"Grajaú"}), 
	(s2{name:"Rio Grande da Serra"}),
	p = shortestPath((s1)-[:CONNECT*]-(s2))
WHERE ALL (x IN RELATIONSHIPS(p) WHERE x.transport='train' OR x.transport='metro')
RETURN EXTRACT(n IN NODES(p) | n.name) AS Directions
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].