Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Construct graph & Append new node/edge based on path only? #59

Open
happyshows opened this issue Sep 2, 2016 · 1 comment
Open

Construct graph & Append new node/edge based on path only? #59

happyshows opened this issue Sep 2, 2016 · 1 comment

Comments

@happyshows
Copy link

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.

@happyshows
Copy link
Author

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant