I guess I should have made it clear: I can go through up to a 2nd degree connection, as long as the first degree relationship is "member_of"
–
Z JonesJul 24 '12 at 1:13

1

If the nodes are connected in some way, you can do the query in Gremlin. However, I have no idea what you're trying to do so I can't give you an example. Please clarify and just state in words exactly what you are trying to do.
–
espeedJul 24 '12 at 4:17

Your clarification wasn't, so much. It would be awesome if you'd tell us about your domain :)
–
Matt LuongoAug 10 '12 at 21:11

Erm, this doesn't seem to really answer the intent of the question. Isn't there a reason he is mentioning relationship types?
–
Matt LuongoAug 10 '12 at 20:41

I'm ignoring the contradiction in the requirements, viz. N5->likes->N2, "that same query started at N5 will return N2", and "I can go through up to a 2nd degree connection, as long as the first degree relationship is 'member_of'".
–
Bobby NortonAug 10 '12 at 21:26

Those aren't necessarily contradictions (though they are pretty muddy). He could mean "give me all related nodes of a node that are not a group, and then all related nodes of a group the node is in". Unfortunately his example graph doesn't include that case, so we don't know.
–
Matt LuongoAug 10 '12 at 21:29

Is the idea that you want to return all incoming and outgoing relationships of a node (person?), and all related nodes of any group of which a person is a member? So "groups" commute their relationships on "members"?

If so, and assuming recursive groups aren't allowed, I've come up with an alternative graph that might illustrate your use case (as I understand it) more clearly -> http://console.neo4j.org/?id=wyr207

on the graph, related would return all directly related nodes, and other_related all other nodes returned from a group, if the node is a member of a group. Combining those is beyond my Cypher ability, but they will be de-duped AFAIK (no nodes in related will be included in other_related).

Try the query in the console link with a few different node ids (N5 has a node id of 1) and see if that's what you were thinking. It would be simple to add relationship direction, etc.

Translating this to Gremlin is a tad bit tedious (pattern matching in Cypher is more natural), but LMK if this is in the right direction and I'll do it.