Im having trouble with addEdge/addE in the latest gremlin console for TP3

4,565 views
Skip to first unread message

Mark Henderson

unread,
Aug 8, 2015, 7:35:16 PM8/8/15
to Gremlin-users
I decided to give the Tinkerpop 3 stack a try an for the life of me I cannot get the addEdge calls to work at all. I get an error saying

No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.addEdge() is applicable for argument types: (java.lang.String, org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) values: [knows, [GraphStep([1700],vertex)]]

From running:

:> g.V(685).addEdge('knows', g.V(1700))

This may be a simple error on my behalf, but I cannot see where I am going wrong. I am following the examples in the latest version of the documentation. Here are the steps that I take

./bin/gremlin.sh

# in the console now

gremlin
> :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> g.addV('name', 'test')
==>v[1848]
gremlin> :> g.addV('name', 'test2')
==>v[1850]
gremlin> :> g.V(1848)
==>v[1848]
gremlin> :> g.V(1850)
==>v[1850]
gremlin> :> g.V(1848).addEdge('knows', g.V(1850))
No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.addEdge() is applicable for argument types: (java.lang.String, org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal) values: [knows, [GraphStep([1850],vertex)]]

I'm not copying the examples word-for-word, but I do feel like I am following along pretty well (http://tinkerpop.incubator.apache.org/docs/3.0.0-incubating/#connecting-via-console). What am I missing?

Thanks.

Other things:

  • Are there sample yaml properties files for graphs? I straight-up copied the tinker graph-empty.properties as my own. I don't see anywhere in the documentation on what properties are allowed and what they do.
  • Is there a list of changes in the overall gremlin language vs. v2? There are quite a few changes, but there doesn't seem to be a place that tells you want has changed.
Thanks again


Daniel Kuppitz

unread,
Aug 8, 2015, 8:12:23 PM8/8/15
to gremli...@googlegroups.com
GraphTraversal::addEdge() doesn't exist. Either use Vertex::addEdge() or GraphTraversal::addOutE() (see: AddEdge Step).

Cheers,
Daniel


--
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-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/64ade2eb-f9df-4d2c-bdb9-aed4fadf4e4e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark Henderson

unread,
Aug 8, 2015, 8:41:10 PM8/8/15
to Gremlin-users
Okay. Based on what you said I was able to get it to work. 

The documentation says, in a few places, that I should be able to do:

g.V($ID1).addEdge($LABEL,g.V($ID2));

But, g.V($ID) returns a DefaultGraphTraversal object, which doesn't have an addEdge method. 

So in order to get this to work, like in the documentation, I had to add a .next() call in order to get an actual Vertex object

g.V($ID1).next().addEdge($LABEL,g.V($ID2).next());

I'm certain that the designers have their reasons, buy why does the interface look like this? In earlier versions it was pretty straight-forward g.addVertex(out, in, label). This seems to be a step backwards, interface-wise. 

Thanks

Daniel Kuppitz

unread,
Aug 8, 2015, 9:35:20 PM8/8/15
to gremli...@googlegroups.com
The documentation says, in a few places, that I should be able to do:
g.V($ID1).addEdge($LABEL,g.V($ID2));

I'm pretty sure that's not true, since almost all the code samples are evaluated during the build process and such a statement would break the evaluation.

buy why does the interface look like this?

I don't remember the exact reason, but you'll probably find some related discussions on the mailing list (a few months back). Or maybe Marko chimes in and provides and answer...... just kidding, now that he saw me mentioning his name, he'll never open this thread again :).

Cheers,
Daniel


Mark Henderson

unread,
Aug 8, 2015, 9:59:12 PM8/8/15
to Gremlin-users
Am I looking at the wrong documentation. I clicked the link that is off of the homepage

 this one clearly says "photos," plural, but when you add more than one it complains (everything sucks :) 

Daniel Kuppitz

unread,
Aug 9, 2015, 5:53:45 AM8/9/15
to gremli...@googlegroups.com
What you highlighted is all Vertex::addEdge(), what you're trying is GraphTraversal::addEdge().

Cheers,
Daniel


Mark Henderson

unread,
Aug 12, 2015, 9:32:26 AM8/12/15
to Gremlin-users
I think the issue I have is that I'm not too certain what types the examples are operating against, if there is a difference between a remote and local graph (:> g.addVertex doesn't work for me), and if the examples are straight groovy code vs gremlin in the console and if that distinction even matters. Either way, I'm getting the hang of it.

I don't seem to able to get an edge by ID (:> e.E($id)) is that still a thing? I don't see any info on it

Stephen Mallette

unread,
Aug 12, 2015, 9:39:56 AM8/12/15
to Gremlin-users
There shouldn't be a difference between remote and local.  I don't know how you have your remote graph setup but by default "g" is bound to GraphTraversalSource and "graph" is bound to a Graph instance, thus g.addVertex() isn't valid.  

what is the "e" in "e.E(id)"? assuming "e" is a GraphTraversalSource, i would expect that to work.



On Wed, Aug 12, 2015 at 9:32 AM, Mark Henderson <emeh...@gmail.com> wrote:
I think the issue I have is that I'm not too certain what types the examples are operating against, if there is a difference between a remote and local graph (:> g.addVertex doesn't work for me), and if the examples are straight groovy code vs gremlin in the console and if that distinction even matters. Either way, I'm getting the hang of it.

I don't seem to able to get an edge by ID (:> e.E($id)) is that still a thing? I don't see any info on it
--
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-user...@googlegroups.com.

Mark Henderson

unread,
Aug 12, 2015, 12:00:59 PM8/12/15
to Gremlin-users
Thank you for the clarification, it was very helpful and wasn't something that I took note of while reading the documentation. 

Yeah the e in 'e.E(ID)' was supposed to be 'g', a GraphTraversalSource, sorry I was on the train trying to bang out the post before it went underground.

I just did some testing in my console and came across something strange: I can get the edge by ID only if I specify the ID while creating the edge:

gremlin> :> g.addV()
==>v[3]
gremlin> :> g.addV()
==>v[4]
gremlin> :> g.V(3).next().addEdge('knows', g.V(4).next())
==>e[5][3-knows->4]
gremlin> :> g.E(5) #no reply
gremlin> :> g.V(3).next().addEdge('knows', g.V(4).next(), T.id, 999)
==>e[999][3-knows->4]
gremlin> :> g.E(999)
==>e[999][3-knows->4]

Is this a configuration issue on my end?

Stephen Mallette

unread,
Aug 12, 2015, 12:04:17 PM8/12/15
to Gremlin-users
It is a configuration issue for TinkerGraph, but you should be wary of this issue for other graphs as well.  Please refer to this section of the docs on TinkerGraph:


Mark Henderson

unread,
Aug 12, 2015, 4:05:57 PM8/12/15
to Gremlin-users
Cool. I didn't notice the edgeIDManager option. Thanks.

Is there a way to persist a TinkerGraph like there was in 2.X?

Also, I am typically a read the code type of dude, but Java isn't a language that I've ever developed anything with. Where should I start looking to get a better understanding of how Gremlin works? I want to know things like which methods are available on which types and what are the varying signatures.

Thanks for your help

Stephen Mallette

unread,
Aug 12, 2015, 4:10:50 PM8/12/15
to Gremlin-users
Is there a way to persist a TinkerGraph like there was in 2.X?

you can only persist TinkerGraph via Graph.io().  
 
Also, I am typically a read the code type of dude, but Java isn't a language that I've ever developed anything with. Where should I start looking to get a better understanding of how Gremlin works? I want to know things like which methods are available on which types and what are the varying signatures.

Not sure about exactly what you're looking for, but how about just using the javadocs?




Mark Henderson

unread,
Aug 12, 2015, 8:53:38 PM8/12/15
to Gremlin-users
Thanks, I'll start reading through that to see what I can come up with. 

I've scanned the TP3 documentation again and I feel that some things are missing. For example: the configuration section that you linked to earlier coupled with the general server configuration section (http://tinkerpop.incubator.apache.org/docs/3.0.0-incubating/#_configuring_2) doesn't make it too clear about how to access the graph that you configured via Gremlin scripts (in my case via the Gremlin server). I found a post that you wrote in June that gives a great explanation of how it works (again, I may have missed where it explains this in the docs): 

... 
Specifically, you could specify the graph name on open() (in this case, "tinkergraph") and it would bind that server-side global Graph variable to "g".  

I didn't think we needed that capability with Gremlin Server because Gremlin Server binds all Graph and TraversalSource instances globally given the names that you configure them with.  Of course, the downside there is that you can't always use a nice "g" for the context of your script so now you're stuck coupling a client side script to some naming configuration that you have in Gremlin Server.  
https://groups.google.com/forum/#!searchin/gremlin-users/specify$20graph|sort:date/gremlin-users/DVZVL4ryH5s/tYgOxylmPGQJ

The documentation isn't very straight-forward with 'g' and 'gremlin' (or whatever your local config server names are) being different object types with different methods available on them. It seems that while TP2 had a few different types, they all shared functionality which made grepping the language a bit easier. But I do totally understand having strict functionality on certain types because it makes things cleaner and less error-prone on the backend. 

The efforts that you guys put into gremlindocs and sql2gremlin helped me understand TP2's flavor a lot. I look forward to the updates and I'm willing to help if at all possible. 

I maintain a couple of Gremlin-related projects: gremlinpy and gizmo and I am updating them to work with TP3 so once I get a better understanding of how things work I will release the libraries and write tutorials on how to use them.

Thanks for the help, I'll have more questions. 

Stephen Mallette

unread,
Aug 13, 2015, 6:39:57 AM8/13/15
to Gremlin-users
If you think you can improve something in the documentation, please submit a pull request and we'll consider the change.

abdell...@gmail.com

unread,
Jun 1, 2018, 5:26:56 AM6/1/18
to Gremlin-users
thank you man !!!

itsmepr...@gmail.com

unread,
Apr 19, 2019, 2:01:29 PM4/19/19
to Gremlin-users
I have tried the same thing as follows, could you help me figuring this out ?


gremlin> g.addV('name', 'test')

==>v[40968432]

gremlin> g.addV('name', 'test2')

==>v[163848240]

gremlin> g.V(40968432).next().addEdge('knows',g.V(163848240).next())

==>e[odyxq-oe3g0-b4lx-2pju40][40968432-knows->163848240]

gremlin> g.E()

23:14:57 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [()]. For better performance, use indexes

==>e[odyxq-oe3g0-b4lx-2pju40][40968432-knows->163848240]

gremlin> g.E(odyxq-oe3g0-b4lx-2pju40)

groovysh_parse: 2: unexpected token: pju40 @ line 2, column 23.

   g.E(odyxq-oe3g0-b4lx-2pju40)

                         ^


1 error

Type ':help' or ':h' for help.

Display stack trace? [yN]

Stephen Mallette

unread,
Apr 20, 2019, 8:05:37 PM4/20/19
to gremli...@googlegroups.com
That's a really old thread - i'd just write one Gremlin traversal:

 g.addV('name', 'test').as('x').
  addV('name', 'test2').as('y').
  addE('knows').from('x').to('y').iterate()

That said, i assume your problem with:

g.E(odyxq-oe3g0-b4lx-2pju40) 

is that you need that to be a string:

g.E("odyxq-oe3g0-b4lx-2pju40") 


jaya prakash

unread,
Apr 21, 2019, 2:29:38 AM4/21/19
to gremli...@googlegroups.com
Let's say , if I want to drop an edge using the Id (and here I'm assuming that i have multiple edges having same label 'knows' ) , then it does throw an error like above . Or else is there any better approach for dropping and edge using the Id  ?

gremlin> g.E().hasLabel('knows')

11:54:26 WARN  org.janusgraph.graphdb.transaction.StandardJanusGraphTx  - Query requires iterating over all vertices [(~label = knows)]. For better performance, use indexes

==>e[215ssj-215x5k-dbmd-oe07s][122888216-knows->40964248]

gremlin> g.E(215ssj-215x5k-dbmd-oe07s).drop()

groovysh_parse: 2: unexpected token: ssj @ line 2, column 8.

   g.E(215ssj-215x5k-dbmd-oe07s).drop()

          ^


1 error

Type ':help' or ':h' for help.

Display stack trace? [yN]

jaya prakash

unread,
Apr 21, 2019, 2:35:56 AM4/21/19
to gremli...@googlegroups.com
@stephen Mallette , Thanks for your help . It worked fine . Since I am a newbie to this gremlin , I was a bit confused while dropping the vertices and edges .  While dropping edge , as you said I made the edge Id to be string and it worked ...!!

Cheers !!
Reply all
Reply to author
Forward
0 new messages