I am trying to ultimately get a hierarchical tree from a more complex graph structure that better matches the underlying problem. While I can easily enough represent the desired end result as Systems and CONNECTS relations, I get stuck when trying to add a new node type Signature between the Systems and CONNECTS relations and query over that.
Say I have this data:
CREATE (jita:System {name: 'Jita'})
CREATE (ikuchi:System {name: 'Ikuchi'})
CREATE (ansila:System {name: 'Ansila'})
CREATE (jita)-[:CONNECTS]->(ikuchi)
CREATE (ikuchi)-[:CONNECTS]->(ansila)
Then what I'm ultimately after can be queried with:
MATCH (root:System {name: 'Jita'})<-[:CONNECTS*..5]->(destination:System)
RETURN root, destination
Resulting in this graph:
However, in reality (pun intended, as this is about a videogame...) Systems have Signatures and some Signatures are connected together effectively forming the CONNECTS relationship seen above.
Now, take this dataset:
CREATE (jita:System {name: 'Jita'})
CREATE (ikuchi:System {name: 'Ikuchi'})
CREATE (ansila:System {name: 'Ansila'})
CREATE (sig1:Signature {id: 'JIT-001'})
CREATE (sig2:Signature {id: 'IKU-001'})
CREATE (sig3:Signature {id: 'IKU-002'})
CREATE (sig4:Signature {id: 'ANS-001'})
CREATE (jita)-[:HAS]->(sig1)
CREATE (ikuchi)-[:HAS]->(sig2)
CREATE (ikuchi)-[:HAS]->(sig3)
CREATE (ansila)-[:HAS]->(sig4)
CREATE (sig1)-[:CONNECTS]->(sig2)
CREATE (sig4)-[:CONNECTS]->(sig3)
Which looks like this when querying for all nodes:
With this, I can query one level of connection between Systems:
MATCH (root:System {name: 'Jita'})-[:HAS]->(sigOrigin:Signature)<-[:CONNECTS]->(sigDestination:Signature)<-[:HAS]-(destination:System)
RETURN root, destination, sigOrigin, sigDestination
Resulting in what I would expect:
Can this query be expanded in a similar fashion to the first example query's [:CONNECTS*..5] part? I guess in a way I would like to take the
-[:HAS]->(sigOrigin:Signature)<-[:CONNECTS]->(sigDestination:Signature)<-[:HAS]-(destination:System)
part and expand/repeat it an arbitrary number of times. I should add that, for this problem, I can reduce the Signatures away from between the Systems in code so that does not necessarily need to be done in Cypher.
Thank you for any help!
PS. Some background: This is for my hobby project which is a navigation tool for the videogame EVE Online. I recently decided to switch to Neo4j for the connection tree generation bit. It's my first time using any graph database and so far I've been loving it!