You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "Stephen Mallette (Jira)" <ji...@apache.org> on 2023/02/16 12:34:00 UTC

[jira] [Commented] (TINKERPOP-2867) Inconsistent results

    [ https://issues.apache.org/jira/browse/TINKERPOP-2867?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17689745#comment-17689745 ] 

Stephen Mallette commented on TINKERPOP-2867:
---------------------------------------------

This is expected behavior. By adding {{select('x')}} you just created a cycle in Gremlin's path. You can observe this by replacing {{cyclicPath()}} with {{path()}} to see what Gremlin is traversing:

{code}
gremlin> g.V().as('x').inE().otherV().select('x').path()
==>[v[0],e[39][27-X->0],v[27],v[0]]
==>[v[0],e[61][3-X->0],v[3],v[0]]
==>[v[0],e[70][3-Y->0],v[3],v[0]]
==>[v[0],e[40][3-Y->0],v[3],v[0]]
==>[v[0],e[59][3-Y->0],v[3],v[0]]
==>[v[18],e[35][15-X->18],v[15],v[18]]
==>[v[18],e[68][24-X->18],v[24],v[18]]
==>[v[18],e[63][9-X->18],v[9],v[18]]
...
{code}

The first vertex Gremlin sees becomes the last vertex Gremlin sees with your use of {{select('x')}}. Note that you can limit the portion of the path that you want Gremlin to evaluate with labels:

{code}
gremlin> g.V().as('x').inE().otherV().as('y').select('x').cyclicPath().from('x').to('y').count()
==>0
{{code}

> Inconsistent results
> --------------------
>
>                 Key: TINKERPOP-2867
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2867
>             Project: TinkerPop
>          Issue Type: Bug
>    Affects Versions: 3.6.1
>            Reporter: Yuancheng
>            Priority: Major
>
> {code:java}
> g.V().as('x').inE().otherV().cyclicPath().count()
> // result: 0
> g.V().inE().otherV().as('x').cyclicPath().count()
> // result: 0
> g.V().as('x').inE().otherV().select('x').cyclicPath().count()
> // result: 50
> g.V().inE().otherV().as('x').select('x').cyclicPath().count()
> // result: 50 {code}
> Dataset:
> {code:java}
> from gremlin_python import statics
> from gremlin_python.structure.graph import Graph
> from gremlin_python.process.graph_traversal import __
> from gremlin_python.process.strategies import *
> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
> from gremlin_python.process.traversal import T
> from gremlin_python.process.traversal import Cardinality
> class GremlinSchemaInit:
>     id = T.id
>     single = Cardinality.single
>     graph = Graph()
>     g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
>     
>     def init_dataset(self):
>         self.g.V().drop().iterate()
>         n1 = self.g.addV('A').property('id', '1').property('p', "node01").next()
>         n2 = self.g.addV('A').property('id', '2').property('p', 'node02').next()
>         n3 = self.g.addV('A').property('id', '3').property('p', 'node03').next()
>         n4 = self.g.addV('A').property('id', '4').property('p', 'node04').next()
>         n5 = self.g.addV('A').property('id', '5').property('p', 'node05').next()
>         n6 = self.g.addV('B').property('id', '6').property('p', 'node06').next()
>         n7 = self.g.addV('B').property('id', '7').property('p', 'node07').next()
>         n8 = self.g.addV('B').property('id', '8').property('p', 'node08').next()
>         n9 = self.g.addV('B').property('id', '9').property('p', 'node09').next()
>         n10 = self.g.addV('B').property('id', '10').property('p', 'node10').next()
>         self.g.addE('X').property('p', 'edge01').from_(n1).to(n2).iterate()
>         self.g.addE('X').property('p', 'edge02').from_(n2).to(n3).iterate()
>         self.g.addE('X').property('p', 'edge03').from_(n3).to(n4).iterate()
>         self.g.addE('X').property('p', 'edge04').from_(n4).to(n5).iterate()
>         self.g.addE('X').property('p', 'edge05').from_(n5).to(n6).iterate()
>         self.g.addE('X').property('p', 'edge06').from_(n6).to(n7).iterate()
>         self.g.addE('X').property('p', 'edge07').from_(n7).to(n8).iterate()
>         self.g.addE('X').property('p', 'edge08').from_(n8).to(n9).iterate()
>         self.g.addE('X').property('p', 'edge09').from_(n9).to(n10).iterate()
>         self.g.addE('X').property('p', 'edge10').from_(n10).to(n1).iterate()
>         self.g.addE('Y').property('p', 'edge11').from_(n2).to(n1).iterate()
>         self.g.addE('Y').property('p', 'edge12').from_(n3).to(n2).iterate()
>         self.g.addE('Y').property('p', 'edge13').from_(n4).to(n3).iterate()
>         self.g.addE('Y').property('p', 'edge14').from_(n5).to(n4).iterate()
>         self.g.addE('Y').property('p', 'edge15').from_(n6).to(n5).iterate()
>         self.g.addE('Y').property('p', 'edge16').from_(n7).to(n6).iterate()
>         self.g.addE('Y').property('p', 'edge17').from_(n8).to(n7).iterate()
>         self.g.addE('Y').property('p', 'edge18').from_(n9).to(n8).iterate()
>         self.g.addE('Y').property('p', 'edge19').from_(n10).to(n9).iterate()
>         self.g.addE('Y').property('p', 'edge20').from_(n1).to(n10).iterate()
>         self.g.addE('X').property('p', 'edge21').from_(n3).to(n9).iterate()
>         self.g.addE('Y').property('p', 'edge22').from_(n6).to(n3).iterate()
>         self.g.addE('Y').property('p', 'edge23').from_(n1).to(n8).iterate()
>         self.g.addE('X').property('p', 'edge24').from_(n2).to(n8).iterate()
>         self.g.addE('Y').property('p', 'edge25').from_(n5).to(n8).iterate()
>         self.g.addE('X').property('p', 'edge26').from_(n7).to(n3).iterate()
>         self.g.addE('Y').property('p', 'edge27').from_(n9).to(n2).iterate()
>         self.g.addE('Y').property('p', 'edge28').from_(n9).to(n6).iterate()
>         self.g.addE('X').property('p', 'edge29').from_(n1).to(n6).iterate()
>         self.g.addE('Y').property('p', 'edge30').from_(n2).to(n1).iterate()
>         self.g.addE('X').property('p', 'edge31').from_(n1).to(n5).iterate()
>         self.g.addE('X').property('p', 'edge32').from_(n2).to(n1).iterate()
>         self.g.addE('X').property('p', 'edge33').from_(n3).to(n5).iterate()
>         self.g.addE('X').property('p', 'edge34').from_(n4).to(n7).iterate()
>         self.g.addE('X').property('p', 'edge35').from_(n5).to(n6).iterate()
>         self.g.addE('X').property('p', 'edge36').from_(n6).to(n5).iterate()
>         self.g.addE('X').property('p', 'edge37').from_(n7).to(n6).iterate()
>         self.g.addE('X').property('p', 'edge38').from_(n8).to(n2).iterate()
>         self.g.addE('X').property('p', 'edge39').from_(n9).to(n7).iterate()
>         self.g.addE('X').property('p', 'edge40').from_(n10).to(n3).iterate()
>         self.g.addE('Y').property('p', 'edge41').from_(n2).to(n1).iterate()
>         self.g.addE('Y').property('p', 'edge42').from_(n8).to(n2).iterate()
>         self.g.addE('Y').property('p', 'edge43').from_(n9).to(n3).iterate()
>         self.g.addE('Y').property('p', 'edge44').from_(n9).to(n4).iterate()
>         self.g.addE('Y').property('p', 'edge45').from_(n2).to(n5).iterate()
>         self.g.addE('Y').property('p', 'edge46').from_(n7).to(n6).iterate()
>         self.g.addE('Y').property('p', 'edge47').from_(n6).to(n7).iterate()
>         self.g.addE('Y').property('p', 'edge48').from_(n3).to(n8).iterate()
>         self.g.addE('Y').property('p', 'edge49').from_(n1).to(n9).iterate()
>         self.g.addE('Y').property('p', 'edge50').from_(n7).to(n10).iterate()
> test = GremlinSchemaInit()
> test.init_dataset() {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)