Skip to content

Instantly share code, notes, and snippets.

@SergioLlana
Created December 28, 2014 15:59
Show Gist options
  • Save SergioLlana/f7da0c8dcf9eaa62599d to your computer and use it in GitHub Desktop.
Save SergioLlana/f7da0c8dcf9eaa62599d to your computer and use it in GitHub Desktop.
= Piping Water =
:neo4j-version: 2.0.0
:author: Shaun Daley
:twitter: @shaundaley1
:tags: resources domain:Shutting Valves and Migrating Infrastructure
== Inspiration
London's antique water distribution network is infamous: it loses a http://www.theguardian.com/commentisfree/2012/may/08/water-industry-pipes-scandal[quarter of the water] supplied to London (spilt into the ground). Consequence: http://www.bbc.co.uk/news/10213835[desalination], massive additional CO2 emissions, road congestion caused by too many emergency excavations and very high water prices for consumers. London's case is severe but not atypical: most cities suffer from the same underlying infrastructure problem. Pipes and valves buried below busy urban streets are inherently difficult and expensive to maintain. Inaccessibility, lack of information, failure to efficiently process data and the high cost of each human intervention in legacy systems all compound to undermine efficient resource distribution.
Modern wireless networking offers the first crucial part in reducing the human time and cost of maintenance, and avoiding environmental damage: modern valves can be remotely (and even autonomously) operated to isolate components and pipe sections; modern flow sensors can transmit cross-section flow rates minute-by-minute. The remaining challenge is to log, model and process these resources on a city scale (London sized) with several hundred million components (pipe sections, valves, pumps, flow sensors, outlets, sources, etc) and the sparse, evolving relations between those components. Neo4j fits this bill perfectly.
To illustrate the domain, we'll eliminate most complexity and focus on a single (but ubiquitous) problem.
_Using the Design for Queryability modeling approach by http://twitter.com/ianrobinson[Ian Robinson]_
=== 1. Application/End-User Goals ===
____
*As an* engineer for a water utility
*I want* to know the accessible (remotely controllable, man-hole-accessible or excavation-accessible) valves for shutting off a set of components.
*So that* we can rapidly isolate a burst pipe, leaking valve or a set of components for replacement.
____
=== 2. Questions To Ask of the Domain ===
____
What is the set of valves that must be closed to isolate the smallest possible part of the network including a set of components?
What is the minimum set of network controllable (or manhole-accessible) valves that must be closed to isolate a set of components?
____
=== 3. Identify Entities ===
____
* Component (pipes, sources, outlets, pumps, flow sensors, etc)
* Connection
* Valve
____
=== 4. Identify Relationships Between Entities ===
----
(:Component) <- [:CONNECTS] - (:Connection) - [:CONNECTS] -> (:Component)
(:Valve) - [:CLOSES] -> (:Connection)
----
Valves are distinct objects with their own relationships e.g. IP address, API key, state information, whether they are manually closed clockwise or anti-clockwise (both valve closing directions exist and are widely prevalent in UK legacy water distribution infrastructure). For efficiency of querying, the nature of connections is duplicated in the relationship also:
----
(:Valve{access:'API'}) -> [:CLOSES] -> (:Connection) -> [:API_CONNECTS] -> (:Component)
(:Valve{access:'Manhole'}) -> [:CLOSES] -> (:Connection) -> [:MANHOLE_CONNECTS] -> (:Component)
(:Valve{access:'Excavation'}) -> [:CLOSES] -> (:Connection) -> [:EXCAV_CONNECTS] -> (:Component)
----
=== Candidate Data Model ===
//hide
//setup
[source,cypher]
----
//EQUIPOS (Team)
CREATE (madrid:Team { name : 'Real Madrid' ,stadium:'Santiago Bernabeu'})
CREATE (malaga:Team { name : 'Malaga', stadium:'La Rosaleda' })
CREATE (levante:Team { name : 'Levante', stadium:'Ciudad de Valencia' })
CREATE (espanyol:Team { name : 'Espanyol', stadium:'Cornella-El Prat' })
CREATE (barcelona:Team { name : 'Barcelona', stadium:'Camp Nou' })
CREATE (atletico:Team { name : 'Atletico de Madrid', stadium:'El Calderon' })
CREATE (valencia:Team { name : 'Valencia', stadium:'Mestalla' })
CREATE (celta:Team { name : 'Celta de Vigo', stadium:'Balaidos' })
CREATE (real:Team { name : 'Real Sociedad', stadium:'Anoeta' })
CREATE (almeria:Team { name : 'Almeria', stadium:'Juegos del Mediterraneo' })
CREATE (athletic:Team { name : 'Athletic club' , stadium:'San Mames'})
CREATE (osasuna:Team { name : 'Osasuna', stadium:'El Sadar' })
CREATE (betis:Team { name : 'Real Betis' , stadium:'Benito Villamarin'})
CREATE (rayo:Team { name : 'Rayo Vallecano' , stadium:'Teresa Rivero'})
CREATE (getafe:Team { name : 'Getafe', stadium:'El Coliseum' })
CREATE (valladolid:Team { name : 'Real Valladolid', stadium:'Jose Zorrilla' })
CREATE (granada:Team { name : 'Granada', stadium:'Los Carmenes' })
CREATE (sevilla:Team { name : 'Sevilla', stadium:'Sanchez Pizjuan' })
CREATE (elche:Team { name : 'Elche', stadium:'Manuel Martinez Valero' })
CREATE (villareal:Team { name : 'Villareal', stadium:'El Madrigal' })
CREATE (prieto:Referee { name : 'Prieto Iglesias' })
CREATE (borbalan:Referee { name : 'Fernandez Borbalan' })
CREATE (lahoz:Referee { name : 'Mateu Lahoz' })
CREATE (cerro:Referee { name : 'Del Cerro Grande' })
CREATE (carballo:Referee { name : 'Velasco Carballo' })
CREATE (estrada:Referee { name : 'Estrada Fernandez' })
CREATE (munuera:Referee { name : 'Martinez Munuera' })
CREATE (gil:Referee { name : 'Gil Manzano' })
CREATE (clos:Referee { name : 'Clos Gomez' })
CREATE (hernandez:Referee { name : 'Hernandez Hernandez' })
CREATE (gonzalez:Referee { name : 'Gonzalez Gonzalez' })
CREATE (fTeixeira:Referee { name : 'Fernando Teixeira Vitienes' })
CREATE (jaTeixeira:Referee { name : 'Jose Antonio Teixeira Vitienes' })
CREATE (iglesias:Referee { name : 'Iglesias Villanueva' })
CREATE (alvarez:Referee { name : 'Alvarez Izquierdo' })
CREATE (muñiz:Referee { name : 'Muñiz Fernandez' })
CREATE (ayza:Referee { name : 'Ayza Gamez' })
CREATE (undiano:Referee { name : 'Undiano Mallenco' })
CREATE (delgado:Referee { name : 'Delgado Ferreiro' })
CREATE (giovani:Player { name : 'Giovanni dos Santos' })
CREATE (giovani)-[:PLAYS_IN]->(villarreal)
CREATE (uche:Player { name : 'Ikechuwku Uche' })
CREATE (uche)-[:PLAYS_IN]->(villarreal)
CREATE (brunoSoriano:Player { name : 'Bruno Soriano' })
CREATE (brunoSoriano)-[:PLAYS_IN]->(villarreal)
CREATE (jaumeCosta:Player { name : 'Jaume Costa' })
CREATE (jaumeCosta)-[:PLAYS_IN]->(villarreal)
CREATE (pereira:Player { name : 'Jonathan Pereira' })
CREATE (pereira)-[:PLAYS_IN]->(villarreal)
CREATE (gabriel:Player { name : 'Gabriel' })
CREATE (gabriel)-[:PLAYS_IN]->(villarreal)
CREATE (musachio:Player { name : 'Musacchio' })
CREATE (musachio)-[:PLAYS_IN]->(villarreal)
CREATE (cani:Player { name : 'Cani' })
CREATE (cani)-[:PLAYS_IN]->(villarreal)
CREATE (trigueros:Player { name : 'Manu Trigueros' })
CREATE (trigueros)-[:PLAYS_IN]->(villarreal)
CREATE (perbet:Player { name : 'Perbet'})
CREATE (perbet)-[:PLAYS_IN]->(villarreal)
CREATE (pina:Player { name : 'Tomas Pina' })
CREATE (pina)-[:PLAYS_IN]->(villarreal)
CREATE (mario:Player { name : 'Mario' })
CREATE (mario)-[:PLAYS_IN]->(villarreal)
CREATE (moi:Player { name : 'Moi Gomez' })
CREATE (moi)-[:PLAYS_IN]->(villarreal)
CREATE (peña:Player { name : 'Peña' })
CREATE (peña)-[:PLAYS_IN]->(valladolid)
CREATE (guerra:Player { name : 'Javi Guerra' })
CREATE (guerra)-[:PLAYS_IN]->(valladolid)
CREATE (rukavina:Player { name : 'Rukavina' })
CREATE (rukavina)-[:PLAYS_IN]->(valladolid)
CREATE (manucho:Player { name : 'Manucho' })
CREATE (manucho)-[:PLAYS_IN]->(valladolid)
CREATE (osorio:Player { name : 'Osorio'})
CREATE (osorio)-[:PLAYS_IN]->(valladolid)
CREATE (rossi:Player { name : 'Rossi' })
CREATE (rossi)-[:PLAYS_IN]->(valladolid)
CREATE (rueda:Player { name : 'Jesus Rueda' })
CREATE (rueda)-[:PLAYS_IN]->(valladolid)
CREATE (oscarGonzalez:Player { name : 'Oscar Gonzalez' })
CREATE (oscarGonzalez)-[:PLAYS_IN]->(valladolid)
CREATE (rama:Player { name : 'Rama' })
CREATE (rama)-[:PLAYS_IN]->(valladolid)
CREATE (feghouli:Player { name : 'Sofiane Feghouli' })
CREATE (feghouli)-[:PLAYS_IN]->(valencia)
CREATE (piatti:Player { name : 'Pablo Piatti' })
CREATE (piatti)-[:PLAYS_IN]->(valencia)
CREATE (parejo:Player { name : 'Dani Parejo' })
CREATE (parejo)-[:PLAYS_IN]->(valencia)
CREATE (mathieu:Player { name : 'Mathieu' })
CREATE (mathieu)-[:PLAYS_IN]->(valencia)
CREATE (jonas:Player { name : 'Jonas' })
CREATE (jonas)-[:PLAYS_IN]->(valencia)
CREATE (vargas:Player { name : 'Vargas' })
CREATE (vargas)-[:PLAYS_IN]->(valencia)
CREATE (keita:Player { name : 'Keita' })
CREATE (keita)-[:PLAYS_IN]->(valencia)
CREATE (fuego:Player { name : 'Javi Fuego' })
CREATE (fuego)-[:PLAYS_IN]->(valencia)
CREATE (alcacer:Player { name : 'Alcacer' })
CREATE (alcacer)-[:PLAYS_IN]->(valencia)
CREATE (jairo:Player { name : 'Jairo Samperio' })
CREATE (jairo)-[:PLAYS_IN]->(sevilla)
CREATE (iborra:Player { name : 'Vicente Iborra' })
CREATE (iborra)-[:PLAYS_IN]->(sevilla)
CREATE (gameiro:Player { name : 'Gameiro' })
CREATE (gameiro)-[:PLAYS_IN]->(sevilla)
CREATE (vitolo:Player { name : 'Vitolo' })
CREATE (vitolo)-[:PLAYS_IN]->(sevilla)
CREATE (mbia:Player { name : 'MBia' })
CREATE (mbia)-[:PLAYS_IN]->(sevilla)
CREATE (rakitic:Player { name : 'Rakitic'})
CREATE (rakitic)-[:PLAYS_IN]->(sevilla)
CREATE (bacca:Player { name : 'Bacca' })
CREATE (bacca)-[:PLAYS_IN]->(sevilla)
CREATE (diegoFigueiras:Player { name : 'Diego Figueiras' })
CREATE (diegoFigueiras)-[:PLAYS_IN]->(sevilla)
CREATE (carrizo:Player { name : 'Carriço' })
CREATE (carrizo)-[:PLAYS_IN]->(sevilla)
CREATE (albertoMoreno:Player { name : 'Alberto Moreno' })
CREATE (albertoMoreno)-[:PLAYS_IN]->(sevilla)
CREATE (fazio:Player { name : 'Fazio' })
CREATE (fazio)-[:PLAYS_IN]->(sevilla)
CREATE (vela:Player { name : 'Carlos Vela'})
CREATE (vela)-[:PLAYS_IN]->(real)
CREATE (agirretxe:Player { name : 'Imanol Agirretxe'})
CREATE (agirretxe)-[:PLAYS_IN]->(real)
CREATE (canales:Player { name : 'Sergio Canales' })
CREATE (canales)-[:PLAYS_IN]->(real)
CREATE (griezmann:Player { name : 'Griezmann'})
CREATE (griezmann)-[:PLAYS_IN]->(real)
CREATE (chori:Player { name : 'Chori Castro' })
CREATE (chori)-[:PLAYS_IN]->(real)
CREATE (bergara:Player { name : 'Bergara' })
CREATE (bergara)-[:PLAYS_IN]->(real)
CREATE (pardo:Player { name : 'Ruben Pardo' })
CREATE (pardo)-[:PLAYS_IN]->(real)
CREATE (iñigoLopez:Player { name : 'Iñigo Lopez' })
CREATE (iñigoLopez)-[:PLAYS_IN]->(real)
CREATE (trashorras:Player { name : 'Roberto Trashorras' })
CREATE (trashorras)-[:PLAYS_IN]->(rayo)
CREATE (larrivey:Player { name : 'Larrivey' })
CREATE (larrivey)-[:PLAYS_IN]->(rayo)
CREATE (ñiguez:Player { name : 'Saul Ñiguez' })
CREATE (ñiguez)-[:PLAYS_IN]->(rayo)
CREATE (sebastian:Player { name : 'Sebastian Fernandez' })
CREATE (sebastian)-[:PLAYS_IN]->(rayo)
CREATE (rochina:Player { name : 'Rochina' })
CREATE (rochina)-[:PLAYS_IN]->(rayo)
CREATE (iago:Player { name : 'Iago' })
CREATE (iago)-[:PLAYS_IN]->(rayo)
CREATE (bueno:Player { name : 'Bueno' })
CREATE (bueno)-[:PLAYS_IN]->(rayo)
CREATE (zeCastro:Player { name : 'Ze Castro' })
CREATE (zeCastro)-[:PLAYS_IN]->(rayo)
CREATE (arbilla:Player { name : 'Arbilla' })
CREATE (arbilla)-[:PLAYS_IN]->(rayo)
CREATE (viera:Player { name : 'Jonathan Viera' })
CREATE (viera)-[:PLAYS_IN]->(rayo)
CREATE (oriol:Player { name : 'Oriol Riera' })
CREATE (oriol)-[:PLAYS_IN]->(osasuna)
CREATE (acuña:Player { name : 'Carlos Javier Acuña' })
CREATE (acuña)-[:PLAYS_IN]->(osasuna)
CREATE (arribas:Player { name : 'Arribas' })
CREATE (arribas)-[:PLAYS_IN]->(osasuna)
CREATE (roberto:Player { name : 'Roberto Torres' })
CREATE (roberto)-[:PLAYS_IN]->(osasuna)
CREATE (armenteros:Player { name : 'Armenteros' })
CREATE (armenteros)-[:PLAYS_IN]->(osasuna)
CREATE (portillo:Player { name : 'Francisco Portillo' })
CREATE (portillo)-[:PLAYS_IN]->(malaga)
CREATE (samuel:Player { name : 'Samuel' })
CREATE (samuel)-[:PLAYS_IN]->(malaga)
CREATE (darder:Player { name : 'Darder'})
CREATE (darder)-[:PLAYS_IN]->(malaga)
CREATE (santaCruz:Player { name : 'Santa Cruz'})
CREATE (santaCruz)-[:PLAYS_IN]->(malaga)
CREATE (amrabat:Player { name : 'Amrabat'})
CREATE (amrabat)-[:PLAYS_IN]->(malaga)
CREATE (camacho:Player { name : 'Ignacio Camacho'})
CREATE (camacho)-[:PLAYS_IN]->(malaga)
CREATE (juanmi:Player { name : 'Juanmi'})
CREATE (juanmi)-[:PLAYS_IN]->(malaga)
CREATE (pabloPerez:Player { name : 'Pablo Perez' })
CREATE (pabloPerez)-[:PLAYS_IN]->(malaga)
CREATE (iakovenco:Player { name : 'Iakovenko' })
CREATE (iakovenko)-[:PLAYS_IN]->(malaga)
CREATE (duda:Player { name : 'Duda' })
CREATE (duda)-[:PLAYS_IN]->(malaga)
CREATE (bale:Player { name : 'Gareth Bale' })
CREATE (bale)-[:PLAYS_IN]->(madrid)
CREATE (morata:Player { name : 'Alvaro Morata' })
CREATE (morata)-[:PLAYS_IN]->(madrid)
CREATE (cr:Player { name : 'Cristiano Ronaldo' })
CREATE (cr)-[:PLAYS_IN]->(madrid)
CREATE (ramos:Player { name : 'Sergio Ramos' })
CREATE (ramos)-[:PLAYS_IN]->(madrid)
CREATE (carvajal:Player { name : 'Carvajal' })
CREATE (carvajal)-[:PLAYS_IN]->(madrid)
CREATE (diMaria:Player { name : 'Di Maria' })
CREATE (diMaria)-[:PLAYS_IN]->(madrid)
CREATE (isco:Player { name : 'Isco' })
CREATE (isco)-[:PLAYS_IN]->(madrid)
CREATE (illarra:Player { name : 'Illarramendi' })
CREATE (illarra)-[:PLAYS_IN]->(madrid)
CREATE (pepe:Player { name : 'Pepe' })
CREATE (pepe)-[:PLAYS_IN]->(madrid)
CREATE (benzema:Player { name : 'Benzema' })
CREATE (benzema)-[:PLAYS_IN]->(madrid)
CREATE (jese:Player { name : 'Jese' })
CREATE (jese)-[:PLAYS_IN]->(madrid)
CREATE (modric:Player { name : 'Modric' })
CREATE (modric)-[:PLAYS_IN]->(madrid)
CREATE (angel:Player { name : 'Ángel Luis Rodríguez' })
CREATE (angel)-[:PLAYS_IN]->(levante)
CREATE (ivanschitz:Player { name : 'Andreas Ivanschitz' })
CREATE (ivanschitz)-[:PLAYS_IN]->(levante)
CREATE (barral:Player { name : 'Barral' })
CREATE (barral)-[:PLAYS_IN]->(levante)
CREATE (pedroLopez:Player { name : 'Pedro Lopez' })
CREATE (pedroLopez)-[:PLAYS_IN]->(levante)
CREATE (navarro:Player { name : 'David Navarro' })
CREATE (navarro)-[:PLAYS_IN]->(levante)
CREATE (diop:Player { name : 'Diop' })
CREATE (diop)-[:PLAYS_IN]->(levante)
CREATE (karabelas:Player { name : 'Nikos Karabelas' })
CREATE (karabelas)-[:PLAYS_IN]->(levante)
CREATE (vintra:Player { name : 'Vintra' })
CREATE (vintra)-[:PLAYS_IN]->(levante)
CREATE (junior:Player { name : 'Mate Junior' })
CREATE (junior)-[:PLAYS_IN]->(levante)
CREATE (ighalo:Player { name : 'Ighalo' })
CREATE (ighalo)-[:PLAYS_IN]->(granada)
CREATE (mainz:Player { name : 'Mainz' })
CREATE (mainz)-[:PLAYS_IN]->(granada)
CREATE (brahimi:Player { name : 'Brahimi'})
CREATE (brahimi)-[:PLAYS_IN]->(granada)
CREATE (elArabi:Player { name : 'El-Arabi'})
CREATE (elArabi)-[:PLAYS_IN]->(granada)
CREATE (riki:Player { name : 'Riki' })
CREATE (riki)-[:PLAYS_IN]->(granada)
CREATE (piti:Player { name : 'Piti' })
CREATE (piti)-[:PLAYS_IN]->(granada)
CREATE (recio:Player { name : 'Recio' })
CREATE (recio)-[:PLAYS_IN]->(granada)
CREATE (murillo:Player { name : 'Jeison Murillo' })
CREATE (murillo)-[:PLAYS_IN]->(granada)
CREATE (marica:Player { name : 'Ciprian Marica' })
CREATE (marica)-[:PLAYS_IN]->(getafe)
CREATE (escudero:Player { name : 'Escudero' })
CREATE (escudero)-[:PLAYS_IN]->(getafe)
CREATE (lafita:Player { name : 'Lafita' })
CREATE (lafita)-[:PLAYS_IN]->(getafe)
CREATE (colunga:Player { name : 'Adrian Colunga' })
CREATE (colunga)-[:PLAYS_IN]->(getafe)
CREATE (pedroLeon:Player { name : 'Pedro Leon' })
CREATE (pedroLeon)-[:PLAYS_IN]->(getafe)
CREATE (lisandro:Player { name : 'Lisandro Lopez' })
CREATE (lisandro)-[:PLAYS_IN]->(getafe)
CREATE (colotto:Player { name : 'Colotto' })
CREATE (colotto)-[:PLAYS_IN]->(espanyol)
CREATE (stuani:Player { name : 'Stuani' })
CREATE (stuani)-[:PLAYS_IN]->(espanyol)
CREATE (cordoba:Player { name : 'Jhon Cordoba' })
CREATE (cordoba)-[:PLAYS_IN]->(espanyol)
CREATE (sergioGarcia:Player { name : 'Sergio Garcia'})
CREATE (sergioGarcia)-[:PLAYS_IN]->(espanyol)
CREATE (pizzi:Player { name : 'Pizzi' })
CREATE (pizzi)-[:PLAYS_IN]->(espanyol)
CREATE (davidLopez:Player { name : 'David Lopez' })
CREATE (davidLopez)-[:PLAYS_IN]->(espanyol)
CREATE (fuentes:Player { name : 'Fuentes' })
CREATE (fuentes)-[:PLAYS_IN]->(espanyol)
CREATE (moreno:Player { name : 'Moreno' })
CREATE (moreno)-[:PLAYS_IN]->(espanyol)
CREATE (boakye:Player { name : 'Boakye' })
CREATE (boakye)-[:PLAYS_IN]->(elche)
CREATE (rodrigues:Player { name : 'Rodrigues' })
CREATE (rodrigues)-[:PLAYS_IN]->(elche)
CREATE (damian:Player { name : 'Damian Suarez' })
CREATE (damian)-[:PLAYS_IN]->(elche)
CREATE (moral:Player { name : 'Manu del Moral' })
CREATE (moral)-[:PLAYS_IN]->(elche)
CREATE (corominas:Player { name : 'Corominas' })
CREATE (corominas)-[:PLAYS_IN]->(elche)
CREATE (herrera:Player { name : 'Cristian Herrera' })
CREATE (herrera)-[:PLAYS_IN]->(elche)
CREATE (marquez:Player { name : 'Javi Marquez' })
CREATE (marquez)-[:PLAYS_IN]->(elche)
CREATE (albacar:Player { name : 'Albacar' })
CREATE (albacar)-[:PLAYS_IN]->(elche)
CREATE (iñigoLopezC:Player { name : 'Iñigo Lopez' })
CREATE (iñigoLopezC)-[:PLAYS_IN]->(celta)
CREATE (charles:Player { name : 'Charles' })
CREATE (charles)-[:PLAYS_IN]->(celta)
CREATE (nolito:Player { name : 'Nolito' })
CREATE (nolito)-[:PLAYS_IN]->(celta)
CREATE (orellana:Player { name : 'Orellana' })
CREATE (orellana)-[:PLAYS_IN]->(celta)
CREATE (mina:Player { name : 'Santi Mina'})
CREATE (mina)-[:PLAYS_IN]->(celta)
CREATE (cabral:Player { name : 'Cabral' })
CREATE (cabral)-[:PLAYS_IN]->(celta)
CREATE (augusto:Player { name : 'Augusto Fernandez' })
CREATE (augusto)-[:PLAYS_IN]->(celta)
CREATE (chica:Player { name : 'Francisco Javier Chica' })
CREATE (chica)-[:PLAYS_IN]->(betis)
CREATE (castro:Player { name : 'Ruben Castro' })
CREATE (castro)-[:PLAYS_IN]->(betis)
CREATE (molina:Player { name : 'Molina' })
CREATE (molina)-[:PLAYS_IN]->(betis)
CREATE (juanfranM:Player { name : 'Juanfran Moreno' })
CREATE (juanfranM)-[:PLAYS_IN]->(betis)
CREATE (salva:Player { name : 'Salva Sevilla' })
CREATE (salva)-[:PLAYS_IN]->(betis)
CREATE (brian:Player { name : 'Brian Rodriguez' })
CREATE (brian)-[:PLAYS_IN]->(betis)
CREATE (paulao:Player { name : 'Paulao' })
CREATE (paulao)-[:PLAYS_IN]->(betis)
CREATE (jordi:Player { name : 'Jordi' })
CREATE (jordi)-[:PLAYS_IN]->(betis)
CREATE (lorenzo:Player { name : 'Lorenzo Reyes' })
CREATE (lorenzo)-[:PLAYS_IN]->(betis)
CREATE (baptistao:Player { name : 'Leo Baptistao' })
CREATE (baptistao)-[:PLAYS_IN]->(betis)
CREATE (alexis:Player { name : 'Alexis Sanchez'})
CREATE (alexis)-[:PLAYS_IN]->(barcelona)
CREATE (messi:Player { name : 'Leo Messi'})
CREATE (messi)-[:PLAYS_IN]->(barcelona)
CREATE (pedro:Player { name : 'Pedro'})
CREATE (pedro)-[:PLAYS_IN]->(barcelona)
CREATE (neymar:Player { name : 'Neymar' })
CREATE (neymar)-[:PLAYS_IN]->(barcelona)
CREATE (iniesta:Player { name : 'Iniesta' })
CREATE (iniesta)-[:PLAYS_IN]->(barcelona)
CREATE (tello:Player { name : 'Tello' })
CREATE (tello)-[:PLAYS_IN]->(barcelona)
CREATE (adriano:Player { name : 'Adriano' })
CREATE (adriano)-[:PLAYS_IN]->(barcelona)
CREATE (cesc:Player { name : 'Cesc Fabregas' })
CREATE (cesc)-[:PLAYS_IN]->(barcelona)
CREATE (pique:Player { name : 'Pique' })
CREATE (pique)-[:PLAYS_IN]->(barcelona)
CREATE (godin:Player { name : 'Diego Godin' })
CREATE (godin)-[:PLAYS_IN]->(atletico)
CREATE (alderweireld:Player { name : 'Alderweireld' })
CREATE (alderweireld)-[:PLAYS_IN]->(atletico)
CREATE (filipe:Player { name : 'Filipe Luis' })
CREATE (filipe)-[:PLAYS_IN]->(atletico)
CREATE (raulGarcia:Player { name : 'Raul Garcia' })
CREATE (raulGarcia)-[:PLAYS_IN]->(atletico)
CREATE (miranda:Player { name : 'Miranda' })
CREATE (miranda)-[:PLAYS_IN]->(atletico)
CREATE (costa:Player { name : 'Diego Costa' })
CREATE (costa)-[:PLAYS_IN]->(atletico)
CREATE (koke:Player { name : 'Koke' })
CREATE (koke)-[:PLAYS_IN]->(atletico)
CREATE (gabi:Player { name : 'Gabi' })
CREATE (gabi)-[:PLAYS_IN]->(atletico)
CREATE (villa:Player { name : 'David Villa' })
CREATE (villa)-[:PLAYS_IN]->(atletico)
CREATE (arda:Player { name : 'Arda Turan' })
CREATE (arda)-[:PLAYS_IN]->(atletico)
CREATE (muniain:Player { name : 'Iker Muniain' })
CREATE (muniain)-[:PLAYS_IN]->(athletic)
CREATE (deMarcos:Player { name : 'De Marcos' })
CREATE (deMarcos)-[:PLAYS_IN]->(athletic)
CREATE (ander:Player { name : 'Ander Herrera' })
CREATE (ander)-[:PLAYS_IN]->(athletic)
CREATE (sanJose:Player { name : 'San Jose' })
CREATE (sanjose)-[:PLAYS_IN]->(athletic)
CREATE (susaeta:Player { name : 'Susaeta' })
CREATE (susaeta)-[:PLAYS_IN]->(athletic)
CREATE (aduriz:Player { name : 'Aduriz'})
CREATE (aduriz)-[:PLAYS_IN]->(athletic)
CREATE (gurpegui:Player { name : 'Gurpegui' })
CREATE (gurpegui)-[:PLAYS_IN]->(athletic)
CREATE (ibai:Player { name : 'Ibai' })
CREATE (ibai)-[:PLAYS_IN]->(athletic)
CREATE (sola:Player { name : 'Kike Sola' })
CREATE (sola)-[:PLAYS_IN]->(athletic)
CREATE (laporte:Player { name : 'Aymeric Laporte' })
CREATE (laporte)-[:PLAYS_IN]->(athletic)
CREATE (rico:Player { name : 'Mikel Rico' })
CREATE (rico)-[:PLAYS_IN]->(athletic)
CREATE (verza:Player { name : 'Verza' })
CREATE (verza)-[:PLAYS_IN]->(almeria)
CREATE (aleix:Player { name : 'Aleix Vidal' })
CREATE (aleix)-[:PLAYS_IN]->(almeria)
CREATE (oscarDiaz:Player { name : 'Oscar Diaz' })
CREATE (oscarDiaz)-[:PLAYS_IN]->(almeria)
CREATE (azeez:Player { name : 'Azeez' })
CREATE (azeez)-[:PLAYS_IN]->(almeria)
CREATE (suso:Player { name : 'Suso' })
CREATE (suso)-[:PLAYS_IN]->(almeria)
CREATE (velez:Player { name : 'Fran Velez' })
CREATE (velez)-[:PLAYS_IN]->(almeria)
CREATE (rodri:Player { name : 'Rodri' })
CREATE (rodri)-[:PLAYS_IN]->(almeria)
CREATE (soriano:Player { name : 'Soriano' })
CREATE (soriano)-[:PLAYS_IN]->(almeria)
CREATE (corona:Player { name : 'Corona' })
CREATE (corona)-[:PLAYS_IN]->(almeria)
CREATE (hicham:Player { name : 'Hicham' })
CREATE (hicham)-[:PLAYS_IN]->(almeria)
CREATE (franRico:Player { name : 'Fran Rico' })
CREATE (franRico)-[:PLAYS_IN]->(almeria)
CREATE (jonathan:Player { name : 'Jonathan' })
CREATE (jonathan)-[:PLAYS_IN]->(almeria)
CREATE (barbosa:Player { name : 'Helder Barbosa' })
CREATE (barbosa)-[:PLAYS_IN]->(almeria)
//JORNADAS (Round)
CREATE (r38:Round { num : 38 })
CREATE (r37:Round { num : 37 })
CREATE (r36:Round { num : 36 })
CREATE (r35:Round { num : 35 })
CREATE (r34:Round { num : 34 })
CREATE (r33:Round { num : 33 })
CREATE (r32:Round { num : 32 })
CREATE (r31:Round { num : 31 })
CREATE (r30:Round { num : 30 })
CREATE (r29:Round { num : 29 })
CREATE (r28:Round { num : 28 })
CREATE (r27:Round { num : 27 })
CREATE (r26:Round { num : 26 })
CREATE (r25:Round { num : 25 })
CREATE (r24:Round { num : 24 })
CREATE (r23:Round { num : 23 })
CREATE (r22:Round { num : 22 })
CREATE (r21:Round { num : 21 })
CREATE (r20:Round { num : 20 })
//PARTIDOS J38
CREATE (m1_38:Match { id: 'm1_38', result: '1-0', numCards: 5 })
CREATE
(malaga)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 1 }]->(m1_38),
(levante)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 4 }]->(m1_38),
(prieto)-[:REFEREED]->(m1_38),
(portillo)-[:SCORED{ numGoals: 1}]->(m1_38)
CREATE (m2_38:Match { id: 'm2_38', result: '3-1', numCards: 0 })
CREATE
(madrid)-[:PLAYED{how: 'home', numGoals: 3, numCards: 0}]->(m2_38),
(espanyol)-[:PLAYED{how: 'away', numGoals: 1, numCards: 0}]->(m2_38),
(borbalan)-[:REFEREED]->(m2_38),
(bale)-[:SCORED{ numGoals: 1}]->(m2_38),
(morata)-[:SCORED{ numGoals: 2}]->(m2_38),
(pizzi)-[:SCORED{ numGoals: 1}]->(m2_38)
CREATE (m3_38:Match { id: 'm3_38', result: '1-1', numCards: 9 })
CREATE
(barcelona)-[:PLAYED{how: 'home', numGoals: 1, numCards: 5}]->(m3_38),
(atletico)-[:PLAYED{how: 'away', numGoals: 1, numCards: 0}]->(m3_38),
(lahoz)-[:REFEREED]->(m3_38),
(alexis)-[:SCORED{ numGoals: 1}]->(m3_38),
(godin)-[:SCORED{ numGoals: 1}]->(m3_38)
CREATE (m4_38:Match { id: 'm4_38', result: '2-1', numCards: 4 })
CREATE
(valencia)-[:PLAYED{how: 'home', numGoals: 2, numCards: 1}]->(m4_38),
(celta)-[:PLAYED{how: 'away', numGoals: 1, numCards: 3}]->(m4_38),
(cerro)-[:REFEREED]->(m4_38),
(iñigoLopezC)-[:SCORED{ numGoals: 1}]->(m4_38),
(piatti)-[:SCORED{ numGoals: 1}]->(m4_38),
(feghouli)-[:SCORED{ numGoals: 1}]->(m4_38)
CREATE (m5_38:Match { id: 'm5_38', result: '1-2', numCards: 5 })
CREATE
(real)-[:PLAYED{how: 'home', numGoals: 1, numCards: 2}]->(m5_38),
(villareal)-[:PLAYED{how: 'away', numGoals: 2, numCards: 3}]->(m5_38),
(carballo)-[:REFEREED]->(m5_38),
(giovani)-[:SCORED{ numGoals: 1}]->(m5_38),
(uche)-[:SCORED{ numGoals: 1}]->(m5_38),
(vela)-[:SCORED{ numGoals: 1}]->(m5_38)
CREATE (m6_38:Match { id: 'm6_38', result: '0-0', numCards: 6 })
CREATE
(almeria)-[:PLAYED{how: 'home', numGoals: 0, numCards: 1}]->(m6_38),
(athletic)-[:PLAYED{how: 'away', numGoals: 0, numCards: 5}]->(m6_38),
(estrada)-[:REFEREED]->(m6_38)
CREATE (m7_38:Match { id: 'm7_38', result: '2-1', numCards: 1 })
CREATE
(osasuna)-[:PLAYED{how: 'home', numGoals: 2, numCards: 1}]->(m7_38),
(betis)-[:PLAYED{how: 'away', numGoals: 1, numCards: 0}]->(m7_38),
(munuera)-[:REFEREED]->(m7_38),
(oriol)-[:SCORED{ numGoals: 1}]->(m7_38),
(acuña)-[:SCORED{ numGoals: 1}]->(m7_38),
(chica)-[:SCORED{ numGoals: 1}]->(m7_38)
CREATE (m8_38:Match { id: 'm8_38', result: '1-2', numCards: 10 })
CREATE
(rayo)-[:PLAYED{how: 'home', numGoals: 1, numCards: 3}]->(m8_38),
(getafe)-[:PLAYED{how: 'away', numGoals: 2, numCards: 7}]->(m8_38),
(gil)-[:REFEREED]->(m8_38),
(marica)-[:SCORED{ numGoals: 2}]->(m8_38),
(trashorras)-[:SCORED{ numGoals: 1}]->(m8_38)
CREATE (m9_38:Match { id: 'm9_38', result: '0-1', numCards: 3 })
CREATE
(valladolid)-[:PLAYED{how: 'home', numGoals: 0, numCards: 1}]->(m9_38),
(granada)-[:PLAYED{how: 'away', numGoals: 1, numCards: 2}]->(m9_38),
(clos)-[:REFEREED]->(m9_38)
CREATE (m10_38:Match { id: 'm10_38', result: '3-1', numCards: 2 })
CREATE
(sevilla)-[:PLAYED{how: 'home', numGoals: 3, numCards: 2}]->(m10_38),
(elche)-[:PLAYED{how: 'away', numGoals: 1, numCards: 0}]->(m10_38),
(hernandez)-[:REFEREED]->(m10_38),
(iborra)-[:SCORED{ numGoals: 2}]->(m10_38),
(jairo)-[:SCORED{ numGoals: 1}]->(m10_38),
(boakye)-[:SCORED{ numGoals: 1}]->(m10_38)
CREATE
(m1_38)-[:BELONG]->(r38),
(m2_38)-[:BELONG]->(r38),
(m3_38)-[:BELONG]->(r38),
(m4_38)-[:BELONG]->(r38),
(m5_38)-[:BELONG]->(r38),
(m6_38)-[:BELONG]->(r38),
(m7_38)-[:BELONG]->(r38),
(m8_38)-[:BELONG]->(r38),
(m9_38)-[:BELONG]->(r38),
(m10_38)-[:BELONG]->(r38)
//PARTIDOS J37
CREATE (m1_37:Match { id: 'm1_37', result: '4-0', numCards: 3 })
CREATE
(villareal)-[:PLAYED{ how: 'home', numGoals: 4, numCards: 1 }]->(m1_37),
(rayo)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 2 }]->(m1_37),
(gonzalez)-[:REFEREED]->(m1_37),
(uche)-[:SCORED{ numGoals: 1}]->(m1_37),
(brunoSoriano)-[:SCORED{ numGoals: 1}]->(m1_37),
(pereira)-[:SCORED{ numGoals: 1}]->(m1_37),
(jaumeCosta)-[:SCORED{ numGoals: 1}]->(m1_37)
CREATE (m2_37:Match { id: 'm2_37', result: '2-0', numCards: 9 })
CREATE
(levante)-[:PLAYED{how: 'home', numGoals: 2, numCards: 5}]->(m2_37),
(valencia)-[:PLAYED{how: 'away', numGoals: 0, numCards: 4}]->(m2_37),
(carballo)-[:REFEREED]->(m2_37) ,
(angel)-[:SCORED{ numGoals: 1}]->(m2_37),
(ivanschitz)-[:SCORED{ numGoals: 1}]->(m2_37)
CREATE (m3_37:Match { id: 'm3_37', result: '1-1', numCards: 4 })
CREATE
(athletic)-[:PLAYED{how: 'home', numGoals: 1, numCards: 2}]->(m3_37),
(real)-[:PLAYED{how: 'away', numGoals: 1, numCards: 2}]->(m3_37),
(cerro)-[:REFEREED]->(m3_37),
(muniain)-[:SCORED{ numGoals: 1}]->(m3_37),
(agirretxe)-[:SCORED{ numGoals: 1}]->(m3_37)
CREATE (m4_37:Match { id: 'm4_37', result: '0-2', numCards: 6 })
CREATE
(granada)-[:PLAYED{how: 'home', numGoals: 0, numCards: 4}]->(m4_37),
(almeria)-[:PLAYED{how: 'away', numGoals: 2, numCards: 2}]->(m4_37),
(gil)-[:REFEREED]->(m4_37),
(verza)-[:SCORED{ numGoals: 1}]->(m4_37),
(aleix)-[:SCORED{ numGoals: 1}]->(m4_37)
CREATE (m5_37:Match { id: 'm5_37', result: '0-0', numCards: 6 })
CREATE
(elche)-[:PLAYED{how: 'home', numGoals: 0, numCards: 3}]->(m5_37),
(barcelona)-[:PLAYED{how: 'away', numGoals: 0, numCards: 3}]->(m5_37),
(fTeixeira)-[:REFEREED]->(m5_37)
CREATE (m6_37:Match { id: 'm6_37', result: '1-1', numCards: 9 })
CREATE
(atletico)-[:PLAYED{how: 'home', numGoals: 1, numCards: 3}]->(m6_37),
(malaga)-[:PLAYED{how: 'away', numGoals: 1, numCards: 6}]->(m6_37),
(jaTeixeira)-[:REFEREED]->(m6_37),
(samuel)-[:SCORED{ numGoals: 1}]->(m6_37),
(alderweireld)-[:SCORED{ numGoals: 1}]->(m6_37)
CREATE (m7_37:Match { id: 'm7_37', result: '1-1', numCards: 1 })
CREATE
(espanyol)-[:PLAYED{how: 'home', numGoals: 1, numCards: 0}]->(m7_37),
(osasuna)-[:PLAYED{how: 'away', numGoals: 1, numCards: 1}]->(m7_37),
(iglesias)-[:REFEREED]->(m7_37),
(coloto)-[:SCORED{ numGoals: 1}]->(m7_37),
(acuña)-[:SCORED{ numGoals: 1}]->(m7_37)
CREATE (m8_37:Match { id: 'm8_37', result: '2-0', numCards: 4 })
CREATE
(celta)-[:PLAYED{how: 'home', numGoals: 2, numCards: 2}]->(m8_37),
(madrid)-[:PLAYED{how: 'away', numGoals: 0, numCards: 2}]->(m8_37),
(hernandez)-[:REFEREED]->(m8_37),
(charles)-[:SCORED{ numGoals: 2}]->(m8_37)
CREATE (m9_37:Match { id: 'm9_37', result: '1-0', numCards: 5 })
CREATE
(getafe)-[:PLAYED{how: 'home', numGoals: 1, numCards: 3}]->(m9_37),
(sevilla)-[:PLAYED{how: 'away', numGoals: 0, numCards: 2}]->(m9_37),
(estrada)-[:REFEREED]->(m9_37),
(escudero)-[:SCORED{ numGoals: 1}]->(m9_37)
CREATE (m10_37:Match { id: 'm10_37', result: '4-3', numCards: 6 })
CREATE
(betis)-[:PLAYED{how: 'home', numGoals: 4, numCards: 4}]->(m10_37),
(valladolid)-[:PLAYED{how: 'away', numGoals: 3, numCards: 2}]->(m10_37),
(alvarez)-[:REFEREED]->(m10_37),
(guerra)-[:SCORED{ numGoals: 2}]->(m10_37),
(peña)-[:SCORED{ numGoals: 1}]->(m10_37),
(molina)-[:SCORED{ numGoals: 1}]->(m10_37),
(castro)-[:SCORED{ numGoals: 1}]->(m10_37),
(juanfranM)-[:SCORED{ numGoals: 1}]->(m10_37)
CREATE
(m1_37)-[:BELONG]->(r37),
(m2_37)-[:BELONG]->(r37),
(m3_37)-[:BELONG]->(r37),
(m4_37)-[:BELONG]->(r37),
(m5_37)-[:BELONG]->(r37),
(m6_37)-[:BELONG]->(r37),
(m7_37)-[:BELONG]->(r37),
(m8_37)-[:BELONG]->(r37),
(m9_37)-[:BELONG]->(r37),
(m10_37)-[:BELONG]->(r37)
//PARTIDOS J36
CREATE (m1_36:Match { id: 'm1_36', result: '0-3', numCards: 5 })
CREATE
(rayo)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 4 }]->(m1_36),
(athletic)-[:PLAYED{ how: 'away', numGoals: 3, numCards: 1 }]->(m1_36),
(borbalan)-[:REFEREED]->(m1_36),
(ander)-[:SCORED{ numGoals: 1}]->(m1_36),
(deMarcos)-[:SCORED{ numGoals: 1}]->(m1_36),
(sanJose)-[:SCORED{ numGoals: 1}]->(m1_36)
CREATE (m2_36:Match { id: 'm2_36', result: '2-2', numCards: 6 })
CREATE
(barcelona)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 3 }]->(m2_36),
(getafe)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 3 }]->(m2_36),
(jaTeixeira)-[:REFEREED]->(m2_36),
(lafita)-[:SCORED{ numGoals: 2}]->(m2_36),
(alexis)-[:SCORED{ numGoals: 1}]->(m2_36),
(messi)-[:SCORED{ numGoals: 1}]->(m2_36)
CREATE (m3_36:Match { id: 'm3_36', result: '0-1', numCards: 6 })
CREATE
(malaga)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 1 }]->(m3_36),
(elche)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 5 }]->(m3_36),
(estrada)-[:REFEREED]->(m3_36),
(rodrigues)-[:SCORED{ numGoals: 1}]->(m3_36)
CREATE (m4_36:Match { id: 'm4_36', result: '0-2', numCards: 1 })
CREATE
(osasuna)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 0 }]->(m4_36),
(celta)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 1 }]->(m4_36),
(gil)-[:REFEREED]->(m4_36),
(nolito)-[:SCORED{ numGoals: 2}]->(m4_36)
CREATE (m5_36:Match { id: 'm5_36', result: '1-0', numCards: 7 })
CREATE
(valladolid)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 3 }]->(m5_36),
(espanyol)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 4 }]->(m5_36),
(muñiz)-[:REFEREED]->(m5_36),
(rukavina)-[:SCORED{ numGoals: 1}]->(m5_36)
CREATE (m6_36:Match { id: 'm6_36', result: '3-2', numCards: 7 })
CREATE
(almeria)-[:PLAYED{ how: 'home', numGoals: 3, numCards: 3 }]->(m6_36),
(betis)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 4 }]->(m6_36),
(iglesias)-[:REFEREED]->(m6_36),
(aleix)-[:SCORED{ numGoals: 1}]->(m6_36),
(azeez)-[:SCORED{ numGoals: 1}]->(m6_36),
(oscarDiaz)-[:SCORED{ numGoals: 1}]->(m6_36),
(salva)-[:SCORED{ numGoals: 1}]->(m6_36),
(brian)-[:SCORED{ numGoals: 1}]->(m6_36)
CREATE (m7_36:Match { id: 'm7_36', result: '1-0', numCards: 5 })
CREATE
(levante)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 2 }]->(m7_36),
(atletico)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 3 }]->(m7_36),
(gonzalez)-[:REFEREED]->(m7_36),
(barral)-[:SCORED{ numGoals: 1}]->(m7_36)
CREATE (m8_36:Match { id: 'm8_36', result: '0-0', numCards: 0 })
CREATE
(sevilla)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 0 }]->(m8_36),
(villareal)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 0 }]->(m8_36),
(prieto)-[:REFEREED]->(m8_36)
CREATE (m9_36:Match { id: 'm9_36', result: '2-2', numCards: 4 })
CREATE
(madrid)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 1 }]->(m9_36),
(valencia)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 3 }]->(m9_36),
(clos)-[:REFEREED]->(m9_36),
(cr)-[:SCORED{ numGoals: 1}]->(m9_36),
(mathieu)-[:SCORED{ numGoals: 1}]->(m9_36),
(ramos)-[:SCORED{ numGoals: 1}]->(m9_36),
(parejo)-[:SCORED{ numGoals: 1}]->(m9_36)
CREATE (m10_36:Match { id: 'm10_36', result: '1-1', numCards: 8 })
CREATE
(real)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 2 }]->(m10_36),
(granada)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 6 }]->(m10_36),
(fTeixeira)-[:REFEREED]->(m10_36),
(vela)-[:SCORED{ numGoals: 1}]->(m10_36),
(ighalo)-[:SCORED{ numGoals: 1}]->(m10_36)
CREATE
(m1_36)-[:BELONG]->(r36),
(m2_36)-[:BELONG]->(r36),
(m3_36)-[:BELONG]->(r36),
(m4_36)-[:BELONG]->(r36),
(m5_36)-[:BELONG]->(r36),
(m6_36)-[:BELONG]->(r36),
(m7_36)-[:BELONG]->(r36),
(m8_36)-[:BELONG]->(r36),
(m9_36)-[:BELONG]->(r36),
(m10_36)-[:BELONG]->(r36)
//PARTIDOS J35
CREATE (m1_35:Match { id: 'm1_35', result: '1-1', numCards: 6 })
CREATE
(elche)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 2 }]->(m1_35),
(levante)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 4 }]->(m1_35),
(gil)-[:REFEREED]->(m1_35),
(angel)-[:SCORED{ numGoals: 1}]->(m1_35),
(boakye)-[:SCORED{ numGoals: 1}]->(m1_35)
CREATE (m2_35:Match { id: 'm2_35', result: '0-3', numCards: 9 })
CREATE
(granada)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 5 }]->(m2_35),
(rayo)-[:PLAYED{ how: 'away', numGoals: 3, numCards: 4 }]->(m2_35),
(lahoz)-[:REFEREED]->(m2_35),
(ñiguez)-[:SCORED{ numGoals: 1}]->(m2_35),
(larrivey)-[:SCORED{ numGoals: 1}]->(m2_35),
(sebastian)-[:SCORED{ numGoals: 1}]->(m2_35)
CREATE (m3_35:Match { id: 'm3_35', result: '1-0', numCards: 15 })
CREATE
(getafe)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 9 }]->(m3_35),
(malaga)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 6 }]->(m3_35),
(muñiz)-[:REFEREED]->(m3_35),
(colunga)-[:SCORED{ numGoals: 1}]->(m3_35)
CREATE (m4_35:Match { id: 'm4_35', result: '4-0', numCards: 0 })
CREATE
(madrid)-[:PLAYED{ how: 'home', numGoals: 4, numCards: 0 }]->(m4_35),
(osasuna)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 0 }]->(m4_35),
(fTeixeira)-[:REFEREED]->(m4_35),
(cr)-[:SCORED{ numGoals: 2}]->(m4_35),
(ramos)-[:SCORED{ numGoals: 1}]->(m4_35),
(carvajal)-[:SCORED{ numGoals: 1}]->(m4_35)
CREATE (m5_35:Match { id: 'm5_35', result: '0-1', numCards: 2 })
CREATE
(betis)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 2 }]->(m5_35),
(real)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 0 }]->(m5_35),
(ayza)-[:REFEREED]->(m5_35),
(vela)-[:SCORED{ numGoals: 1}]->(m5_35)
CREATE (m6_35:Match { id: 'm6_35', result: '1-2', numCards: 10 })
CREATE
(espanyol)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 7 }]->(m6_35),
(almeria)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 3 }]->(m6_35),
(hernandez)-[:REFEREED]->(m6_35),
(stuani)-[:SCORED{ numGoals: 1}]->(m6_35),
(velez)-[:SCORED{ numGoals: 1}]->(m6_35),
(suso)-[:SCORED{ numGoals: 1}]->(m6_35)
CREATE (m7_35:Match { id: 'm7_35', result: '0-1', numCards: 5 })
CREATE
(valencia)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 3 }]->(m7_35),
(atletico)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 2 }]->(m7_35),
(undiano)-[:REFEREED]->(m7_35),
(raulGarcia)-[:SCORED{ numGoals: 1}]->(m7_35)
CREATE (m8_35:Match { id: 'm7_35', result: '3-1', numCards: 8 })
CREATE
(athletic)-[:PLAYED{ how: 'home', numGoals: 3, numCards: 2 }]->(m8_35),
(sevilla)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 6 }]->(m8_35),
(alvarez)-[:REFEREED]->(m8_35),
(gameiro)-[:SCORED{ numGoals: 1}]->(m8_35),
(ander)-[:SCORED{ numGoals: 1}]->(m8_35),
(munian)-[:SCORED{ numGoals: 1}]->(m8_35),
(susaeta)-[:SCORED{ numGoals: 1}]->(m8_35)
CREATE (m9_35:Match { id: 'm9_35', result: '2-3', numCards: 6 })
CREATE
(villareal)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 3 }]->(m9_35),
(barcelona)-[:PLAYED{ how: 'away', numGoals: 3, numCards: 3 }]->(m9_35),
(borbalan)-[:REFEREED]->(m9_35),
(messi)-[:SCORED{ numGoals: 1}]->(m9_35),
(cani)-[:SCORED{ numGoals: 1}]->(m9_35),
(trigueros)-[:SCORED{ numGoals: 1}]->(m9_35)
CREATE (m10_35:Match { id: 'm10_35', result: '4-1', numCards: 5 })
CREATE
(celta)-[:PLAYED{ how: 'home', numGoals: 4, numCards: 1 }]->(m10_35),
(valladolid)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 4 }]->(m10_35),
(jaTeixeira)-[:REFEREED]->(m10_35),
(manucho)-[:SCORED{ numGoals: 1}]->(m10_35),
(nolito)-[:SCORED{ numGoals: 2}]->(m10_35),
(charles)-[:SCORED{ numGoals: 1}]->(m10_35)
CREATE
(m1_35)-[:BELONG]->(r35),
(m2_35)-[:BELONG]->(r35),
(m3_35)-[:BELONG]->(r35),
(m4_35)-[:BELONG]->(r35),
(m5_35)-[:BELONG]->(r35),
(m6_35)-[:BELONG]->(r35),
(m7_35)-[:BELONG]->(r35),
(m8_35)-[:BELONG]->(r35),
(m9_35)-[:BELONG]->(r35),
(m10_35)-[:BELONG]->(r35)
//PARTIDOS J34
CREATE (m1_34:Match { id: 'm1_34', result: '2-0', numCards: 8 })
CREATE
(atletico)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 2 }]->(m1_34),
(elche)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 6 }]->(m1_34),
(clos)-[:REFEREED]->(m1_34),
(costa)-[:SCORED{ numGoals: 1}]->(m1_34),
(miranda)-[:SCORED{ numGoals: 1}]->(m1_34)
CREATE (m2_34:Match { id: 'm2_34', result: '1-1', numCards: 5 })
CREATE
(osasuna)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 3 }]->(m2_34),
(valencia)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 2 }]->(m2_34),
(estrada)-[:REFEREED]->(m2_34),
(jonas)-[:SCORED{ numGoals: 1}]->(m2_34),
(oriol)-[:SCORED{ numGoals: 1}]->(m2_34)
CREATE (m3_34:Match { id: 'm3_34', result: '0-0', numCards: 9 })
CREATE
(levante)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 4 }]->(m3_34),
(getafe)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 5 }]->(m3_34),
(fTeixeira)-[:REFEREED]->(m3_34)
CREATE (m4_34:Match { id: 'm4_34', result: '2-1', numCards: 1 })
CREATE
(real)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 0 }]->(m4_34),
(espanyol)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 1 }]->(m4_34),
(carballo)-[:REFEREED]->(m4_34),
(vela)-[:SCORED{ numGoals: 1}]->(m4_34),
(canales)-[:SCORED{ numGoals: 1}]->(m4_34),
(cordoba)-[:SCORED{ numGoals: 1}]->(m4_34)
CREATE (m5_34:Match { id: 'm5_34', result: '2-4', numCards: 5 })
CREATE
(almeria)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 5 }]->(m5_34),
(celta)-[:PLAYED{ how: 'away', numGoals: 4, numCards: 0 }]->(m5_34),
(muñiz)-[:REFEREED]->(m5_34),
(nolito)-[:SCORED{ numGoals: 2}]->(m5_34),
(oscarDiaz)-[:SCORED{ numGoals: 1}]->(m5_34),
(orellana)-[:SCORED{ numGoals: 1}]->(m5_34),
(charles)-[:SCORED{ numGoals: 1}]->(m5_34),
(rodri)-[:SCORED{ numGoals: 1}]->(m5_34)
CREATE (m6_34:Match { id: 'm6_34', result: '3-1', numCards: 5 })
CREATE
(rayo)-[:PLAYED{ how: 'home', numGoals: 3, numCards: 3 }]->(m6_34),
(betis)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 2 }]->(m6_34),
(hernandez)-[:REFEREED]->(m6_34),
(chica)-[:SCORED{ numGoals: 1}]->(m6_34),
(larrivey)-[:SCORED{ numGoals: 1}]->(m6_34),
(rochina)-[:SCORED{ numGoals: 1}]->(m6_34)
CREATE (m7_34:Match { id: 'm7_34', result: '4-0', numCards: 2 })
CREATE
(sevilla)-[:PLAYED{ how: 'home', numGoals: 4, numCards: 2 }]->(m7_34),
(granada)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 0 }]->(m7_34),
(jaTeixeira)-[:REFEREED]->(m7_34),
(vitolo)-[:SCORED{ numGoals: 1}]->(m7_34),
(mbia)-[:SCORED{ numGoals: 1}]->(m7_34),
(gameiro)-[:SCORED{ numGoals: 1}]->(m7_34)
CREATE (m8_34:Match { id: 'm8_34', result: '2-1', numCards: 5 })
CREATE
(barcelona)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 2 }]->(m8_34),
(athletic)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 3 }]->(m8_34),
(munuera)-[:REFEREED]->(m8_34),
(messi)-[:SCORED{ numGoals: 1}]->(m8_34),
(pedro)-[:SCORED{ numGoals: 1}]->(m8_34),
(aduriz)-[:SCORED{ numGoals: 1}]->(m8_34)
CREATE (m9_34:Match { id: 'm9_34', result: '2-0', numCards: 7 })
CREATE
(malaga)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 4 }]->(m9_34),
(villareal)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 3 }]->(m9_34),
(alvarez)-[:REFEREED]->(m9_34),
(darder)-[:SCORED{ numGoals: 1}]->(m9_34),
(santaCruz)-[:SCORED{ numGoals: 1}]->(m9_34)
CREATE (m10_34:Match { id: 'm10_34', result: '1-1', numCards: 8 })
CREATE
(valladolid)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 4 }]->(m10_34),
(madrid)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 8 }]->(m10_34),
(gil)-[:REFEREED]->(m10_34),
(osorio)-[:SCORED{ numGoals: 1}]->(m10_34),
(ramos)-[:SCORED{ numGoals: 1}]->(m10_34)
CREATE
(m1_34)-[:BELONG]->(r34),
(m2_34)-[:BELONG]->(r34),
(m3_34)-[:BELONG]->(r34),
(m4_34)-[:BELONG]->(r34),
(m5_34)-[:BELONG]->(r34),
(m6_34)-[:BELONG]->(r34),
(m7_34)-[:BELONG]->(r34),
(m8_34)-[:BELONG]->(r34),
(m9_34)-[:BELONG]->(r34),
(m10_34)-[:BELONG]->(r34)
//PARTIDOS J33
CREATE (m1_33:Match { id: 'm1_33', result: '0-0', numCards: 1 })
CREATE
(osasuna)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 0 }]->(m1_33),
(valladolid)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 1 }]->(m1_33),
(clos)-[:REFEREED]->(m1_33)
CREATE (m2_33:Match { id: 'm2_33', result: '2-2', numCards: 9 })
CREATE
(celta)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 4 }]->(m2_33),
(real)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 5 }]->(m2_33),
(estrada)-[:REFEREED]->(m2_33),
(canales)-[:SCORED{ numGoals: 1}]->(m2_33),
(griezmann)-[:SCORED{ numGoals: 1}]->(m2_33),
(mina)-[:SCORED{ numGoals: 1}]->(m2_33),
(nolito)-[:SCORED{ numGoals: 1}]->(m2_33)
CREATE (m3_33:Match { id: 'm3_33', result: '1-0', numCards: 4 })
CREATE
(villareal)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 2 }]->(m3_33),
(levante)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 2 }]->(m3_33),
(hernandez)-[:REFEREED]->(m3_33),
(perbet)-[:SCORED{ numGoals: 1}]->(m3_33)
CREATE (m4_33:Match { id: 'm4_33', result: '1-0', numCards: 3 })
CREATE
(granada)-[:PLAYED{ how: 'home', numGoals: 1, numCards: 0 }]->(m4_33),
(barcelona)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 3 }]->(m4_33),
(delgado)-[:REFEREED]->(m4_33),
(brahimi)-[:SCORED{ numGoals: 1}]->(m4_33)
CREATE (m5_33:Match { id: 'm5_33', result: '4-0', numCards: 0 })
CREATE
(madrid)-[:PLAYED{ how: 'home', numGoals: 4, numCards: 0 }]->(m5_33),
(almeria)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 0 }]->(m5_33),
(munuera)-[:REFEREED]->(m5_33),
(morata)-[:SCORED{ numGoals: 1}]->(m5_33),
(isco)-[:SCORED{ numGoals: 1}]->(m5_33),
(bale)-[:SCORED{ numGoals: 1}]->(m5_33),
(diMaria)-[:SCORED{ numGoals: 1}]->(m5_33)
CREATE (m6_33:Match { id: 'm6_33', result: '0-2', numCards: 9 })
CREATE
(betis)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 5 }]->(m6_33),
(sevilla)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 4 }]->(m6_33),
(carballo)-[:REFEREED]->(m6_33),
(gameiro)-[:SCORED{ numGoals: 2}]->(m6_33)
CREATE (m7_33:Match { id: 'm7_33', result: '2-1', numCards: 8 })
CREATE
(valencia)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 6 }]->(m7_33),
(elche)-[:PLAYED{ how: 'away', numGoals: 1, numCards: 2 }]->(m7_33),
(alvarez)-[:REFEREED]->(m7_33),
(parejo)-[:SCORED{ numGoals: 1}]->(m7_33),
(corominas)-[:SCORED{ numGoals: 1}]->(m7_33),
(piatti)-[:SCORED{ numGoals: 1}]->(m7_33)
CREATE (m8_33:Match { id: 'm8_33', result: '0-2', numCards: 7 })
CREATE
(getafe)-[:PLAYED{ how: 'home', numGoals: 0, numCards: 4 }]->(m8_33),
(atletico)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 3 }]->(m8_33),
(borbalan)-[:REFEREED]->(m8_33),
(costa)-[:SCORED{ numGoals: 1}]->(m8_33),
(godin)-[:SCORED{ numGoals: 1}]->(m8_33)
CREATE (m9_33:Match { id: 'm9_33', result: '2-2', numCards: 4 })
CREATE
(espanyol)-[:PLAYED{ how: 'home', numGoals: 2, numCards: 1 }]->(m9_33),
(rayo)-[:PLAYED{ how: 'away', numGoals: 2, numCards: 3 }]->(m9_33),
(undiano)-[:REFEREED]->(m9_33),
(iago)-[:SCORED{ numGoals: 1}]->(m9_33),
(stuani)-[:SCORED{ numGoals: 1}]->(m9_33),
(colotto)-[:SCORED{ numGoals: 1}]->(m9_33),
(larrivey)-[:SCORED{ numGoals: 1}]->(m9_33)
CREATE (m10_33:Match { id: 'm10_33', result: '3-0', numCards: 4 })
CREATE
(athletic)-[:PLAYED{ how: 'home', numGoals: 3, numCards: 0 }]->(m10_33),
(malaga)-[:PLAYED{ how: 'away', numGoals: 0, numCards: 4 }]->(m10_33),
(gonzalez)-[:REFEREED]->(m10_33),
(ander)-[:SCORED{ numGoals: 1}]->(m10_33),
(aduriz)-[:SCORED{ numGoals: 2}]->(m10_33)
CREATE
(m1_33)-[:BELONG]->(r33),
(m2_33)-[:BELONG]->(r33),
(m3_33)-[:BELONG]->(r33),
(m4_33)-[:BELONG]->(r33),
(m5_33)-[:BELONG]->(r33),
(m6_33)-[:BELONG]->(r33),
(m7_33)-[:BELONG]->(r33),
(m8_33)-[:BELONG]->(r33),
(m9_33)-[:BELONG]->(r33),
(m10_33)-[:BELONG]->(r33)
----
// graph
==== Isolate the Burst Pipe Using Only Remote Calls to API-Accessible Valves ====
[source,cypher]
----
START burstPipe=node:node_auto_index(name='BurstPipe')
MATCH (burstPipe)-[:CONNECTS|EXCAV_CONNECTS|MANHOLE_CONNECTS*0..]-()-[:API_CONNECTS]- (h)-[:CLOSES]-(v{access:'API'})
RETURN v
----
// table
// console
== Extension
For real world application, there are some necessary modifications (e.g. modelling state information in relationships, such as whether a connection is presently closed or scheduled for opening/closing; limiting query depth and notifying of query failure in event of maximum query depth being reached).
In real world application, extending the above model, there is potential for adding greater value still:
____
- estimating the marginal water savings from replacing any defined set of components
- estimating the resilience of network water pressure to failure of specific pumps (both current and under hypothetical modifications to the network)
- scheduling replacement or state-change of parts, and communicating this seamlessly (and automatically) in real time to all other parties that this might affect
etc
____
This approach is more generic than it may initially seem. Many resource problems involve networks of distribution in which many components interact across sparse relationships (electricity generation and distribution, natural gas, sewage, district-piped heating); rapid and efficient querying on these relationships is necessary for efficient resource allocation and better environmental and cost outcomes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment