Marko, I am thinking of using this statement. g.V.ifThenElse{it.out('hasCentre').filter{it == aCentre}.hasNext()}{}{println "${it} has center unknown"}
to get nodes that DO NOT have a relationship, is this the best way to do it? I guess so, if this is the case, I am now adding support to the .NET graph client to support ifThenElse expressions. I am wondering though, as I am designing the interface for it, can and ifThenElse have nested ifThenElse expressions as well? I guess "it" and _() can be used within them? Cheers -----Original Message----- From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On Behalf Of Marko Rodriguez Sent: Saturday, 3 December 2011 4:10 AM To: Neo4j user discussions Subject: Re: [Neo4j] Gremlin Query - Help Hi, > Scenario 1: > I would like to get all Nodes that do not have a relationship to another > node. What is the best way to do this Gremlin? > > Root => NodeA => NodeB > Root => NodeC > > Output should be NodeC I don't understand the problem. > Scenario 2: > Root = > User -> Centre > > I would like to get all centres for userA, and then get all users who > are also linked to the same centres of the userA userA.out('hasCentre').in('hasCentre').except([userA]) > Scenario 3: > User => Centre > I would like to get all users that do not have a link to a Centre, and if > this is the case, do a projection that returns a fake centre with property > "Unknown" g.V.ifThenElse{it.out('hasCentre').filter{it == aCentre}.hasNext()}{}{println "${it} has center unknown"} If you have an index of your Users, then its more efficient to hit that index, then iterate through all vertices (g.V). E.g. g.idx(T.v)[[type:'User']].ifThenElse.... > Scenario 4: > > REFERRAL => PERSON > > I would like to combine a query that gets all Referrals that are > linked to a person and project a table result (contains referrals and > person property values (this is easy to do) However, I then want to do a > SPLIT query, that gets referrals without the persons, and then MERGE both > back into the table projection? So table projecton might look like this. > I guess this is done with .table().it{}....cap, but what I am not sure, is > how to do a split and merge in parallel and then get that merge projected > into the same table. I don't quite understand your problem, but here is an example of splitting and merging. g.v(1).out('knows').copySplit(_().out('knows').name, _().out('created').name).fairMerge This will get all the people that v[1] knows and then generate two parallel pipeline. Each friend of v[1] is copied to each of the 2 parallel pipelines. One pipeline will get their friend's names and one will get their created project's names. It will then merge those two parallel pipelines into a single stream. You can do either fairMerge or exhaustMerge depending on the merging algorithm you want. fairMerge is more memory efficient. I need to write more about split/merge in the Gremlin documentation. https://github.com/tinkerpop/gremlin/wiki/Split-Merge-Pattern <-- will work on it :) HTH, Marko. http://markorodriguez.com _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user