Construct graph & Append new node/edge based on path only?
happyshows opened this issue · 1 comments
Hi,
I wanted to create a graph without having to define node info and purely based on the list of relation info (linear).
for example, RelA,RelB,RelC,RelD, in this path, it involves 5 nodes (anonymous) and 4 defined edges.
what I did manually is below:
CREATE (n)-[:RelA]->(m)
MATCH (x)-[:RelA]->(n)
WITH n
CREATE (n)-[:RelB]->(m)
MATCH (x)-[:RelA]->(y)-[:RelB]->(n)
WITH n
CREATE (n)-[:RelC]->(m)
MATCH (x)-[:RelA]->(y)-[:RelB]->(z)-[:RelC]->(n)
WITH n
CREATE (n)-[:RelC]->(b)
The reason for the complicated matching is because there might be other paths which indicate a different branch, for example:
RelA,RelB1,RelC,RelD In this case, the starting node and 2nd node will be identical with the nodes created above, however, the 3rd node (after RelB1) is different from the 3rd node above. Consequently, the 4th and 5th Node will be different although the relation is the same. They are different because the starting point (3rd node) is different now.
createRel does not allow anonymous node and also query can only take one statement. I'm wondering if there's easier way to achieve my goal. Maybe patch the path info using igraph first and then bulk load into Neo4j and remove node info?