Re: hey guys ,how to query a person relational depth


李平 <lipin...@...>
 

ok  thanks   ,another question , how to skip a super vertex ,this vertex has lots of edge ,for example .the phone is 911 or this phone is custom service,  so a lots of people has relation with this vertex , when I query a person two layer relation depth, it will query a lots of person
custom service;


在 2017年8月25日星期五 UTC+8上午2:32:17,Daniel Kuppitz写道:

Any of the following 2 queries should do the trick:

gremlin> g.V().has('name','A').
           repeat(out('hasPhone').in('hasPhone').simplePath()).emit().
           project('name','depth').
             by('name').
             by(path().count(local))
==>[name:C,depth:3]
==>[name:G,depth:3]
==>[name:E,depth:5]

gremlin> g.V().has('name','A').
           repeat(out('hasPhone').in('hasPhone').simplePath().as('x')).emit().
           project('name','depth').
             by('name').
             by(select(all, 'x').count(local))
==>[name:C,depth:1]
==>[name:G,depth:1]
==>[name:E,depth:2]

Pretty much depends on how you define "relation depth".

Cheers,
Daniel




On Wed, Aug 23, 2017 at 7:26 PM, 李平 <li...@...> wrote:
gremlin> g.addV().property('name', 'A').as('a'). addV().property('phone', '110').as('b'). addV().property('name', 'C').as('c'). addV().property('phone', '111').as('d'). addV().property('name', 'E').as('e'). addV().property('phone', '112').as('f'). addV().property('name', 'G').as('g'). addE('hasPhone').from('a').to('b'). addE('hasPhone').from('c').to('d'). addE('hasPhone').from('c').to('b'). addE('hasPhone').from('e').to('d').
addE('hasPhone').from('e').to('f'). addE('hasPhone').from('g').to('b').iterate()



if I want to know vertex A's relation depth how to write the gremlin commond,   

I  write like this 

g.V().has('userId','1').repeat(__.as("a").out().in().where(neq("a"))).emit().path().count(local).max()



but it seem endless loop,
在 2017年8月23日星期三 UTC+8下午9:16:21,Jason Plurad写道:
There's a recipe for this http://tinkerpop.apache.org/docs/current/recipes/#_maximum_depth

On Wednesday, August 23, 2017 at 3:52:14 AM UTC-4, 李平 wrote:
I want to know ,one person in the janusGraph ,his relational depth,use gremlin

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.