Yet another example

Daniel Kuppitz doesn't mean to stop posting very useful scripts on the gremlin-users mailing list and this one is no different. Thanks Daniel!

g = TinkerGraph.open()
p = g.addVertex("name", "Erez")
a1 = g.addVertex("name", "Anthem of the Sun")
a2 = g.addVertex("name", "Anthem of the Sun Remixed")
s1 = g.addVertex("name", "Cryptical Envelopment")
s2 = g.addVertex("name", "The Faster We Go, the Rounder We Get")
s3 = g.addVertex("name", "We Leave the Castle")
p.addEdge("OWNS", a1)
p.addEdge("OWNS", a2)
a1.addEdge("CONTAINS", s1)
a1.addEdge("CONTAINS", s2)
a1.addEdge("CONTAINS", s3)
a2.addEdge("CONTAINS", s1)

gremlin> p.out("OWNS").out("CONTAINS").path().by("name").group().by { [it.get(0), it.get(2)] }.next().grep { it.value.size() > 1 }*.value.flatten()
==>[Erez, Anthem of the Sun, Cryptical Envelopment]
==>[Erez, Anthem of the Sun Remixed, Cryptical Envelopment]

FIXME Somehow it doesn't work in the current setup :(

gremlin> g.V().has("name","Erez").match('a',
gremlin>     g.of().as('a').out("OWNS").as('b'),
gremlin>     g.of().as('a').out("OWNS").as('c'),
gremlin>     g.of().as('b').out("CONTAINS").as('d'),
gremlin>     g.of().as('c').out("CONTAINS").as('d')
gremlin> ).where('b', neq, 'c').select('a','c','d').by("name").dedup().map { it.get().values() }

==>[Erez, Anthem of the Sun, Cryptical Envelopment]
==>[Erez, Anthem of the Sun Remixed, Cryptical Envelopment]

FIXME This script doesn't work, either :(

g.V().has("name","Erez").as("a").out("OWNS").as("b").out("CONTAINS").as("c").in("CONTAINS").except("b").in("OWNS").retain("a").select("a","b","c").by("name").dedup().map { it.get().values() }

FIXME Doh, that one doesn't work, either!

results matching ""

    No results matching ""