A F
╲ ╱
C -> D -> E
╱ ╲
B G
From left to right, all edges shown above are outgoing edges (A and B point to C; C points to D; D points to E; E points to F and G).
Given the following query:
g.V().hasLabel('label').or(
__.in('edge').out('edge').has('value', 'G'), // traversal #1
__.in('edge').in('edge').out('edge').has('value', 'G'), // traversal #2 __.in('edge').out('edge').out('edge').has('value', 'G'), // traversal #3 __.in('edge').in('edge').out('edge').out('edge').has('value', 'G') // traversal #4)
I get back vertices E, F, and G, which makes sense to me. Traversals #1 and #4 both yield F and G; traversal #3 yields E; traversal #2 yields nothingI figured that I could also represent the query above as follows:
g.V().hasLabel('label').or(__.repeat(__.in('edge')).times(2).emit().dedup().out().has('value', 'G'), // traversal #5 __.repeat(__.in('edge')).times(2).emit().dedup().out().out().has('value', 'G') // traversal #6)
As I expected, this query also returns vertices E, F, and G.I then tried to see if the following query could achieve the same result:
g.V().hasLabel('label').or(__.repeat(__.in('edge')).times(2).emit().dedup().repeat(out('edge')).times(2).emit().dedup().has('value', 'G') // traversal #7)This, however, returns vertices A, C, E, F and G, which does not make sense to me. Can anyone explain why this query returns vertices A and C?My expectation was that the final ".has('value', 'G')" clause would filter out A and C because both are at least 3 hops away from G, and the "repeat(out('edge'))" is only "times(2)".Furthermore, when I execute the *inverse* of this query (i.e. reverse edge directions and target vertex A):g.V().hasLabel('label').or(__.repeat(out('edge')).times(2).emit().dedup().repeat(__.in('edge')).times(2).emit().dedup().has('value', 'A') // traversal #8)I am getting back vertices A, B, and C, which I would expected. There seems to be a discrepancy here, given that this query is the same as query #3, just inverted.I'd be eternally grateful if someone could shed some light on this situation.Best Regards,Eric Steele
One correction to make: Traversals #1 yields only G, #4 yields both F and G; traversal #3 yields E; traversal #2 yields nothing
g.V().hasLabel('label').or(
__.in('edge').out('edge').has('value', 'G'), // traversal #1
__.in('edge').in('edge').out('edge').has('value', 'G'), // traversal #2 __.in('edge').out('edge').out('edge').has('value', 'G'), // traversal #3 __.in('edge').in('edge').out('edge').out('edge').has('value', 'G') // traversal #4)
gremlin> g.V().hasLabel('label').or(__.repeat(__.in('edge')).times(2).emit().dedup().repeat(out('edge')).times(2).emit().dedup().has('value', 'G')).valueMap()
==>[value:[E]]
==>[value:[F]]
==>[value:[G]]
gremlin> g.V().hasLabel('label').valueMap()
==>[value:[A]]
==>[value:[B]]
==>[value:[C]]
==>[value:[D]]
==>[value:[E]]
==>[value:[F]]
==>[value:[G]]
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/b047853b-664b-401d-909c-3efe0c07b1de%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
gremlin> Gremlin.version
==>3.2.4-20170124-6a0001ac
gremlin> g.withPath().V().hasLabel('label').or(
gremlin> repeat(__.in('edge')).times(2).emit().dedup().repeat(out('edge')).times(2).emit().dedup().has('value', 'G').
gremlin> sideEffect {println it.path().objects()*.value("value")}
gremlin> ).values()
==>E
==>G
==>A
==>F
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/9fd5df39-9dcc-4487-ae69-01a594fae72c%40googlegroups.com.