changing relation edge

474 views
Skip to first unread message

Tiago Braga Machado

unread,
Nov 20, 2017, 5:06:11 PM11/20/17
to Gremlin-users
Hi,

Is it possible changing relation of edges without drop edge? Changing from, to and label for example.

Thanks.

Stephen Mallette

unread,
Nov 21, 2017, 7:00:14 AM11/21/17
to Gremlin-users
No you can't make that change in place like that - the vertices bound to an edge are immutable. With Gremlin, you simply have to drop the edge and add it back (copying in the properties). I suppose you could check the API of the specific graph database you are using to see if it has a way to do that, but I'm not aware of any that do.

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/14b7a164-472d-4ce7-8abd-d6bc8be58265%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Daniel Kuppitz

unread,
Nov 21, 2017, 10:01:14 AM11/21/17
to Gremlin-users
If you're looking for a single query solution, check this:

Changing the in-vertex of the knows edge between marko and vadas to peter and using a different label for the edge:

gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V(1).outE().inV().path().by('name').by(valueMap(true))
==>[marko,[label:created,id:9,weight:0.4],lop]
==>[marko,[label:knows,id:7,weight:0.5],vadas]
==>[marko,[label:knows,id:8,weight:1.0],josh]
 
gremlin> g.V(1).as('a').outE('knows').as('e1').filter(inV().hasId(2)).
           V(6).addE('knows2').from('a').as('e2').
             sideEffect(select('e1').properties().unfold().as('p').
                        select('e2').property(select('p').key(), select('p').value())).
             select('e1').drop()

gremlin> g.V(1).outE().inV().path().by('name').by(valueMap(true))
==>[marko,[label:knows2,id:13,weight:0.5],peter]
==>[marko,[label:created,id:9,weight:0.4],lop]
==>[marko,[label:knows,id:8,weight:1.0],josh]

Cheers,
Daniel
Reply all
Reply to author
Forward
0 new messages