How can I store this kind of graph in neo4j for fast traversal?

Posted by James on Stack Overflow See other posts from Stack Overflow or by James
Published on 2010-03-11T01:35:28Z Indexed on 2010/03/11 21:14 UTC
Read the original article Hit count: 240

Filed under:
|

This is a graph whose nodes exist in many connected components at once because a node's relationships are a collection of edge groups such that only one edge per edge group can be present at once. I need to be able to find all of the connected components that a node exists in. What would be the best way to store this graph in neo4j to quickly find all of the connected components that a node exists in? Is there a way to use the built in traversals to do this?

Also: is there a name for this kind of graph? I'd appreciate any help/ideas.

Update:

Sorry for not being clear. All nodes are of the same type. Nodes have a variable number of edge groups. Exactly one edge from each edge group needs to be chosen for a particular connected component. I'm going to try to explain through example:

Node x1 is related to: (x2 or x3 or x4) AND (x5 or x6) AND (x7)
Node x2 is related to: (x8) AND (x9 or x10)

So x1's first edge group is (x2, x3, x4), its second edge group is (x5, x6), and its third edge group is (x7).

So here are a few connected components that x1 exists in:

CC1:

x1 is related to: x2, x5, x7
x2 is related to: x8 x9 

CC2:

x1 is related to: x2, x6, x7
x2 is related to: x8, x9

CC3:

x1 is related to: x3, x5, x7

CC4:

x1 is related to: x3, x6, x7

etc.

I'm grateful for your help in this.

© Stack Overflow or respective owner

Related posts about neo4j

Related posts about algorithm