Hello Michael, I am stunned. I was already happy from the input of the first post. Thanks a lot for spending the time to illustrate it in detail. I will need a day to research it.
Best Regards Sebastian On Tuesday, September 16, 2014 10:56:49 PM UTC+2, Michael Hunger wrote: > > I tried to put it together but have no realistic data to model it in a > graph gist. > Would be fun to load actual train stations, routes and reseverations with > LOAD CSV into a graphgist though. > > http://gist.neo4j.org/?dropbox-14493611%2Ftrain-stops_reseverations.txt > > Hope it helps > > Michael > > On Tue, Sep 16, 2014 at 10:35 PM, Michael Hunger < > [email protected] <javascript:>> wrote: > >> Hi Sebastian, >> >> I'm not sure I understand your model. >> >> The relationships between stations are one seat of segments of the same >> train-trip ? >> >> I wonder why you didn't model the train with it's wagons and seats as >> nodes and then connect the seat nodes with a RESERVED_FROM releationship to >> the stations from which it is reseved? >> >> and the :Train also being connected to a :Trip or :Route which has a >> start-time at the first station and connections between the stations as >> :Stop >> >> (:Train {trainNo})<-[:IN_TRAIN]-(:Wagon {wagonNo})<-[:IN_WAGON]-(:Seat >> {seatNo})-[:RESERVED_FROM]->(:Stop) >> >> then you should be able to find all :Seats which have no :RESERVED_FROM >> relationship between the stations that you look at >> >> or probably just subtract those with a RESERVED_FROM relationship from >> all seats in your train. >> >> REGARDING YOUR MODEL: >> >> Did you look into allShortestPaths for your path search? An unlimited >> path search explodes the numbers of paths looked at >> and your WITH statement in between you inhibit the planner to pull in >> your conditions into the path matching. >> >> match p=(d:Station {name: >> 'Berlin-stop-01'})-[r1:train]->()-[r:train*]->(a:Station >> {name: 'Berlin-stop-07'}) >> WHERE r1.reserved = false AND all(r2 in r WHERE r2.reseved = false and >> r2.seat = r1.seat and r2.trainnumber = r1.trainnumber) >> >> perhaps it even makes sense to split up the match. >> >> On Tue, Sep 16, 2014 at 10:01 PM, Sebastian Hennebrueder < >> [email protected] <javascript:>> wrote: >> >>> Hi all. >>> >>> My data presents seats in trains, which can be booked. I am struggling >>> to get a search for a bookable seat reasonable fast. >>> >>> Data sample: >>> >>> create (source:Station {name: 'Berlin-stop-01'}), (target:Station {name: >>> 'Berlin-stop-02'}), (source)-[:train {trainnumber: "abc", seat: "1", >>> reserved: false}]->(target) >>> >>> I am using the following data scenario: >>> >>> 50 stops, 50 seats, 10 different train numbers >>> >>> For every seat and train number there is a relation between two stations. >>> >>> The query I use is: >>> >>> match p=(d:Station {name: 'Berlin-stop-01'})-[r:train*]->(a:Station >>> {name: 'Berlin-stop-07'}) >>> with head(relationships(p)) as r1,p where r1.reserved = false and all(r2 >>> in relationships(p) where r2.seat=r1. seat and r2.trainnumber = >>> r1. trainnumber) >>> return r1 as `r` limit 1 >>> >>> With longer distances between the stops, the database becomes >>> unresponsive. I tried to use start to fix the destination and arrival but >>> did not get any major improvements. >>> >>> I would appreciate any help. >>> >>> Best Regards >>> >>> Sebastian >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Neo4j" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
