How to efficiently create a vertex with a label and several properties?

1k views Asked by At

I want to create a vertex with a given label and some properties. Since the g.addVertexWithLabel() method only takes the label as an argument and I cannot find any v.addLabel() method, it seems that I have to add the properties one by one after creating the vertex.

Or am I missing something here?

1

There are 1 answers

2
stephen mallette On BEST ANSWER

No. As of Titan 0.5.4, there is no API that allows you to add it all at once. In fact, even the Gremlin Groovy sugar of:

g.addVertex([name:"stephen"]) 

just calls Element.setProperty(k,v) for each key/value pair in the Map. In TinkerPop3 and Titan 0.9/1.0, you can do:

g.addVertex(T.label,"person","name","stephen")

so it is a bit nicer assuming you are using the newer version.