Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Paths between nodes excluding certain edges
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Luiz Celso Gomes Jr.  
View profile  
 More options Nov 9 2012, 11:01 am
From: "Luiz Celso Gomes Jr." <luizce...@gmail.com>
Date: Fri, 9 Nov 2012 14:01:12 -0200
Local: Fri, Nov 9 2012 11:01 am
Subject: Paths between nodes excluding certain edges

Hi, all!

I need to find the paths between two nodes following both in/out edges but
excluding edges whose labels are in a list. Below is the solution I came up
with, but it isn't working. Is there an easier way of doing that?

Thanks!

def g = TinkerGraphFactory.createTinkerGraph()
def origs = [g.v(4)]
def dest = '2'

def NOTFOLLOW = ["bla"]

def paths = origs._().as('start')
.copySplit(
_().inE.filter{!(it.label in NOTFOLLOW)}.outV,
 _().outE.filter{!(it.label in NOTFOLLOW)}.inV
).fairMerge()
.simplePath().loop('start'){it.loops<=3}{(it.object.id==dest)}
 .path().toList()
paths.each{println it}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Celso Gomes Jr.  
View profile  
 More options Nov 9 2012, 2:35 pm
From: "Luiz Celso Gomes Jr." <luizce...@gmail.com>
Date: Fri, 9 Nov 2012 17:34:54 -0200
Local: Fri, Nov 9 2012 2:34 pm
Subject: Re: Paths between nodes excluding certain edges

It's funny that if I don't use the "loop" step, just copying the code
multiple times, everything works perfectly. Would that be a bug? Or am I
doing something wrong in the loop parameters?

E.g., this works:

paths = origs._().as('start')
.copySplit(
 _().inE.filter{!(it.label in NOTFOLLOW)}.outV,
_().outE.filter{!(it.label in NOTFOLLOW)}.inV
 ).fairMerge()
.simplePath()
 .copySplit(
 _().inE.filter{!(it.label in NOTFOLLOW)}.outV,
_().outE.filter{!(it.label in NOTFOLLOW)}.inV
 ).fairMerge()
.simplePath()
        .path().toList()

I do need the loop step though..
:(
Thanks

On Fri, Nov 9, 2012 at 2:01 PM, Luiz Celso Gomes Jr. <luizce...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Mallette  
View profile  
 More options Nov 11 2012, 1:11 pm
From: Stephen Mallette <spmalle...@gmail.com>
Date: Sun, 11 Nov 2012 13:11:55 -0500
Local: Sun, Nov 11 2012 1:11 pm
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges
I took the recipe that finds paths between vertices in gremlindocs

http://gremlindocs.com/#recipes/paths-between-two-vertices

and modified it slightly so that it has multiple starts looking for
destinations at v[5] and has edge label filtering:

gremlin> origs = [g.v(1),g.v(3)]
==>v[1]
==>v[3]
gremlin> origs._().both('knows','created').loop(1){it.loops<=3 &&
!(it.object.id in ['1','5'])}.has('id','5').path
==>[v[1], v[4], v[5]]
==>[v[1], v[3], v[4], v[5]]
==>[v[3], v[4], v[5]]

perhaps that will help you solve your problem...

Stephen

On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Celso Gomes Jr.  
View profile  
 More options Nov 11 2012, 1:16 pm
From: "Luiz Celso Gomes Jr." <luizce...@gmail.com>
Date: Sun, 11 Nov 2012 16:16:32 -0200
Local: Sun, Nov 11 2012 1:16 pm
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges

That's nice Stephen, thanks. The problem is that I don't know which edges
to traverse. I just know which edges not to traverse. It's been
surprisingly hard to find a way around it.
:(

On Sun, Nov 11, 2012 at 4:11 PM, Stephen Mallette <spmalle...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marko Rodriguez  
View profile  
 More options Nov 11 2012, 3:44 pm
From: Marko Rodriguez <okramma...@gmail.com>
Date: Sun, 11 Nov 2012 13:43:49 -0700
Local: Sun, Nov 11 2012 3:43 pm
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges

Hi,

What do you mean, "edges not to traverse." By label? If so, you can do:

        x = ['a','b','c']
        origs._().both.filter{!x.contains(it.label)}.loop(2){ ... }

In a future release, we will be support has and hasNot with ORing values.

        https://github.com/tinkerpop/gremlin/issues/308

HTH,
Marko.

http://markorodriguez.com

On Nov 11, 2012, at 11:16 AM, Luiz Celso Gomes Jr. wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Celso Gomes Jr.  
View profile  
 More options Nov 11 2012, 5:32 pm
From: "Luiz Celso Gomes Jr." <luizce...@gmail.com>
Date: Sun, 11 Nov 2012 20:32:12 -0200
Local: Sun, Nov 11 2012 5:32 pm
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges

Thanks Marko, but you are filtering out nodes, not edges, right? I need to
avoid certain edges (that's why I had that complicated code in the first
email, so that I could use filter in the edges).

Makes sense?

Thanks!

On Sun, Nov 11, 2012 at 6:43 PM, Marko Rodriguez <okramma...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marko Rodriguez  
View profile  
 More options Nov 11 2012, 5:52 pm
From: Marko Rodriguez <okramma...@gmail.com>
Date: Sun, 11 Nov 2012 15:52:14 -0700
Local: Sun, Nov 11 2012 5:52 pm
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges

Hi,

Sorry, my code snippet is wrong. Do this:

        x = ['a','b','c']
        origs._().bothE.filter{!x.contains(it.label)}.bothV.loop(2){ ... }

Therefore, only edges that do not have labels specified in x.

HTH,
Marko.

http://markorodriguez.com

On Nov 11, 2012, at 3:32 PM, Luiz Celso Gomes Jr. wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Luiz Celso Gomes Jr.  
View profile  
 More options Nov 11 2012, 6:45 pm
From: "Luiz Celso Gomes Jr." <luizce...@gmail.com>
Date: Sun, 11 Nov 2012 21:45:46 -0200
Local: Sun, Nov 11 2012 6:45 pm
Subject: Re: Paths between nodes excluding certain edges

I think this doubles the number of nodes, because bothV returns the head
and tail of any edge not filtered. I'm pretty sure about that, but I'll
test again when I get to my computer.

Maybe the best solution would be to add a variant of the both (and in/out)
step in gremlin? I think I could try that in the near future...

Marko, what about the code in the first email? Do you see any obivious
error? That code would do it for me, but I was getting a weird behavior. If
you think the code makes some sense, I'll look into whats going on.

Thanks a bunch!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen Mallette  
View profile  
 More options Nov 17 2012, 6:29 am
From: Stephen Mallette <spmalle...@gmail.com>
Date: Sat, 17 Nov 2012 06:29:26 -0500
Local: Sat, Nov 17 2012 6:29 am
Subject: Re: [TinkerPop] Re: Paths between nodes excluding certain edges
I've been tinkering with this issue since it posted and can't quite
get it right.   Luiz, did you ever get it figured out?

Stephen

On Sun, Nov 11, 2012 at 6:45 PM, Luiz Celso Gomes Jr.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »