public transportation of s o paulo in a graph database
play

Public transportation of So Paulo in a graph database IGOR ROZANI - PowerPoint PPT Presentation

Public transportation of So Paulo in a graph database IGOR ROZANI Igor Rozani IgorRozani IgorRozani @IgorRozani IgorRozani Table of contents Whats this project? The database Query examples Q&A The Hunger Games


  1. Public transportation of São Paulo in a graph database IGOR ROZANI

  2. Igor Rozani IgorRozani IgorRozani @IgorRozani IgorRozani

  3. Table of contents ▪ What’s this project? ▪ The database ▪ Query examples ▪ Q&A ▪ The Hunger Games

  4. What’s this project?

  5. What’s this project?

  6. Query examples • Which lines does a company own? • What station is part of which line? • How many stations have each line? • What is the shortest way between stations?

  7. Which lines does a company own? Company Lines MATCH (c:Company)-[:OWN]-(l:Line) "CPTM" ["7 - Ruby", "8 - Diamond", "9 - Emerald", "10 - WITH c, l Turquoise", "11 - Coral", "12 ORDER BY l.number, l.name - Sapphire", "13 - Jade", "Airport Connect", "Airport WITH c, collect(CASE WHEN l.number IS NULL Express", "Touristic THEN l.name ELSE l.number + ' - ' + l.name END) as lines Express"] ... ... RETURN c.name AS Company, lines AS Lines "ViaMobilidade" ["5 - Lilac"] ORDER BY c.name "ViaQuatro" ["4 - Yellow"]

  8. What station is part of which line? MATCH (l:Line)-[:PART_OF]-(s) RETURN l.name AS Line, collect(s.name) AS Stations Line Stations "Blue" ["Jabaquara", "Tiradentes", "Praça da Árvore", "Portuguesa - Tietê", "Luz", "São Bento", "Carandiru", "Parada Inglesa", "São Judas", "Saúde", "Paraíso", "Conceição", "Liberdade", "Jardim São Paulo - Ayrton Senna", "São Joaquim", "Santa Cruz", "Vergueiro", "Armênia", "Sé", "Ana Rosa", "Santana", "Tucuruvi", "Vila Mariana"] "Green" ["Trianon-Masp", "Vila Prudente", "Chácara Klabin", "Santuário Nossa senhora de Fátima - Sumaré", "Ana Rosa", "Clínicas", "Santos Imigrantes", "Vila Madalena", "Paraíso", "Brigadeiro", "Consoloação", "Alto do Ipiranga", "Tamanduateí", "Sacomã"] "Red" ["Anhangabaú", "Artur Alvim", "Bresser - Mooca", "Guilermina - Esperança", "Mal. Deodoro", "Belém", "Pedro II", "Tatuapé", "República", "Patriarca", "Carrão", "Sé", "Penha", "Corinthians - Itaquera", "Vila Matilde", "Brás", "Palmeiras - Barra Funda", "Santa Cecília"]

  9. How many stations have each line? Line qtd "Blue" 23 MATCH (l:Line)-[:PART_OF]-(s) "Diamond" 20 WITH l, count(s) as qtd "Red" 18 "Emerald" 18 RETURN l.name as Line, qtd "Lilac" 17 ORDER BY qtd DESC ... ... "Diamond - Operational Extension" 3 "Jade" 3 "Orca Shuttle Service" 2 "Airport Express" 2

  10. What is the shortest way between stations?

  11. What is the shortest way between stations? MATCH x = shortestPath((s1{name:"Grajaú"})-[:CONNECT*]-(s2{name:"Rio Grande da Serra"})) RETURN EXTRACT(n IN NODES(x) | n.name) AS Directions Directions ["Grajaú", "Primavera - Interlagos", "Autódromo", "Jurubatuba", "Socorro", "Santo Amaro", "Granja Julieta", "Morumbi", " Brooklin “, "Diadema", "Piraporinha", "São Bernardo", "Santo André", "Capuava", "Mauá", "Guapituba", "Ribeirão Pires", "Rio Grande da Serra"]

  12. What is the shortest way between stations?

  13. What is the shortest way between stations? 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 Directions ["Grajaú", "Primavera - Interlagos", "Autódromo", "Jurubatuba", "Socorro", "Santo Amaro", "Largo Treze", "Adolpho Pinheiro", "Alto da Boa Vista", "Borba Gato", "Brooklin", "Campo Belo", "Eucaliptos", "Moema", "AACD - Servidor", "Hospital São Paulo", "Vila Mariana", "Chácara Klabin", "Santos Imigrantes", "Alto do Ipiranga", "Sacomã", "Tamanduateí", "São Caetano do Sul", "Utinga", "Prefeito Saladino", "Santo André", "Capuava", "Mauá", "Guapituba", "Ribeirão Pires", "Rio Grande da Serra"]

  14. What is the shortest way between stations?

  15. Learn more about it This project is available on GitHub. https://github.com/IgorRozani/Public-Transport-SP-Graph-Database

  16. Q&A

  17. Thank you!

  18. The Hunger Games 1 - Which of the following options is not a node label in 3 - Which of the queries can get the shortest path between the project? two stations, using only train transport? A) MetroStation B) PointOfInterest C) Connect A) MATCH (s1{name:"Grajaú"}), (s2{name:"Rio Grande da 2 - What does the following query do? Serra"}), MATCH (n) WHERE n.hasBikeAttachingPost = true OR p = shortestPath((s1)-[:CONNECT*]-(s2)) n.hasBikeParkingTerminal = true WHERE ALL (x IN RELATIONSHIPS(p) WHERE x.transport='train') RETURN n.name ORDER BY n.name DESC RETURN EXTRACT(n IN NODES(p) | n.name) AS Directions A) Get all nodes that have true in the property "hasBikeAttachingPost" or "hasBikeParkingTerminal" and B) MATCH (s1{name:"Grajaú"}), (s2{name:"Rio Grande da return the property "name" sorted by descending order Serra"}), p = shortestPath((s1)-[:CONNECT*]-(s2)) B) Get all nodes that have true in the property WHERE ALL (x IN RELATIONSHIPS(p) WHERE x.transport='train' "hasBikeAttachingPost" and "hasBikeParkingTerminal" OR x.transport='metro') and return the property "name" sorted by descending RETURN EXTRACT(n IN NODES(p) | n.name) AS Directions order C) Get all nodes that have true in the property C) MATCH x = shortestPath((s1{name:"Grajaú"})-[:CONNECT*]- "hasBikeAttachingPost" or "hasBikeParkingTerminal" and (s2{name:"Rio Grande da Serra"})) return the property "name" sorted by ascending order RETURN EXTRACT(n IN NODES(x) | n.name) AS Directions Answer here: http://r.neo4j.com/hunger-games

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend