Hi.

I'm using Neo4j in a personal project, modeling a board game called Ticket 
to Ride.

What I need to accomplish is a core part of game play that's really easy 
for humans but I can't sort out how to get this done with Cypher.

Basic game play is "claiming" routes between cities, say New York <-> 
Washington DC, or New York <-> Pittsburgh. Or in terms of Cypher:

match (c:City {name "New York"})-[r:Route]-(end:City) return end;

+---------------------------------+
| end                             |
+---------------------------------+
| Node[666]{name:"Washington DC"} |
| Node[666]{name:"Washington DC"} |
| Node[655]{name:"Pittsburgh"}    |
| Node[655]{name:"Pittsburgh"}    |
| Node[648]{name:"Montreal"}      |
| Node[633]{name:"Boston"}        |
| Node[633]{name:"Boston"}        |
+---------------------------------+
7 rows



Additionally, the game also has "Destination Cards" that grants the player 
points when they complete a circuit from e.g. Dallas <-> New York. These 
are like "composite edges" that require claiming routes in such a way that 
you have an unbroken line between Dallas & New York. If I were to query for 
all the paths that would complete the destination card in Cypher, it might 
look like this (I'm keeping it to 5 hops or fewer for brevity):

match (c1:City), (c2:City), p = (c1)-[r*..5]-(c2) where c2.name = "New York" 
and c1.name = "Dallas" return distinct nodes(p);
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| nodes(p)                                                                 
                                                                            
                          |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [Node[637]{name:"Dallas"},Node[652]{name:"Oklahoma 
City"},Node[645]{name:"Little 
Rock"},Node[658]{name:"Saint Louis"},Node[655]{name:"Pittsburgh"},Node[651]{
name:"New York"}] |
| [Node[637]{name:"Dallas"},Node[652]{name:"Oklahoma 
City"},Node[645]{name:"Little 
Rock"},Node[649]{name:"Nashville"},Node[655]{name:"Pittsburgh"},Node[651]{
name:"New York"}]   |
| [Node[637]{name:"Dallas"},Node[652]{name:"Oklahoma 
City"},Node[643]{name:"Kansas 
City"},Node[658]{name:"Saint Louis"},Node[655]{name:"Pittsburgh"},Node[651]{
name:"New York"}] |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[658]{name:"Saint 
Louis"},Node[655]{name:"Pittsburgh"},Node[651]{name:"New York"}]           
                      |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[658]{name:"Saint 
Louis"},Node[649]{name:"Nashville"},Node[655]{name:"Pittsburgh"},Node[651]{
name:"New York"}]     |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[658]{name:"Saint 
Louis"},Node[636]{name:"Chicago"},Node[655]{name:"Pittsburgh"},Node[651]{
name:"New York"}]       |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[649]{name:
"Nashville"},Node[658]{name:"Saint Louis"},Node[655]{name:"Pittsburgh"},Node
[651]{name:"New York"}]     |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[649]{name:
"Nashville"},Node[657]{name:"Raleigh"},Node[666]{name:"Washington DC"},Node[
651]{name:"New York"}]      |
| [Node[637]{name:"Dallas"},Node[645]{name:"Little Rock"},Node[649]{name:
"Nashville"},Node[655]{name:"Pittsburgh"},Node[651]{name:"New York"}]       
                            |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9 rows



My question is, if I have a jumble of nodes, and the routes between them, 
what is the best way to sort out if among that jumble there is a circuit 
that completes the destination card?

Sorry if this is poorly worded, I have a hard time phrasing the question 
for myself.

-- 
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.

Reply via email to