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}
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:
> 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'
<luizce...@gmail.com> wrote:
> 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:
>> 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'
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:
> perhaps that will help you solve your problem...
> Stephen
> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
> <luizce...@gmail.com> wrote:
> > 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?
> > 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:
> >> 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'
> 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:
> I took the recipe that finds paths between vertices in gremlindocs
> perhaps that will help you solve your problem...
> Stephen
> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
> <luizce...@gmail.com> wrote:
> > 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?
> > 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:
> >> 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'
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:
> On Nov 11, 2012, at 11:16 AM, Luiz Celso Gomes Jr. wrote:
> 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:
>> I took the recipe that finds paths between vertices in gremlindocs
>> perhaps that will help you solve your problem...
>> Stephen
>> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
>> <luizce...@gmail.com> wrote:
>> > 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?
>> > 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:
>> >> 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'
> 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:
> 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.
> On Nov 11, 2012, at 11:16 AM, Luiz Celso Gomes Jr. wrote:
>> 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:
>> I took the recipe that finds paths between vertices in gremlindocs
>> perhaps that will help you solve your problem...
>> Stephen
>> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
>> <luizce...@gmail.com> wrote:
>> > 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?
>> > 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:
>> >> 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'
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.
On Sunday, November 11, 2012, Marko Rodriguez wrote:
> 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.
> On Nov 11, 2012, at 3:32 PM, Luiz Celso Gomes Jr. wrote:
> 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:
> 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.
> On Nov 11, 2012, at 11:16 AM, Luiz Celso Gomes Jr. wrote:
> 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:
> I took the recipe that finds paths between vertices in gremlindocs
> perhaps that will help you solve your problem...
> Stephen
> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
> <luizce...@gmail.com> wrote:
> > 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?
> > 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:
> >> 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 NOTFOLLO
<luizce...@gmail.com> wrote:
> 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!
> On Sunday, November 11, 2012, Marko Rodriguez wrote:
>> 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.
>> On Nov 11, 2012, at 3:32 PM, Luiz Celso Gomes Jr. wrote:
>> 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:
>> 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.
>> On Nov 11, 2012, at 11:16 AM, Luiz Celso Gomes Jr. wrote:
>> 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:
>> I took the recipe that finds paths between vertices in gremlindocs
>> perhaps that will help you solve your problem...
>> Stephen
>> On Fri, Nov 9, 2012 at 2:34 PM, Luiz Celso Gomes Jr.
>> <luizce...@gmail.com> wrote:
>> > 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?
>> > 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:
>> >> 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 NOTFOLLO