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

Reply via email to