I'm trying to understand the differences in methods, and the best syntax for adding edges (between existing vertices) in Gremlin-Python.
Having read several posts here on SO, I've subdivided some different approaches I found into a few questions.
Many thanks for any feedback in advance!
1) What is the best order of adding properties to the edge, while creating it: which one of these would be the better option (in case there is any significant difference at all)?
g.V().property("prop1", "prop1_val").as_("a")
.V().property("prop2", "prop2_val").as_("b")
.addE("some_relationship")
# rest of traversal option 1:
.property("prop1_val_weight", 0.1d)
.from_("a").to("b")
# rest of traversal option 2:
.from_("a").to("b")
.property("prop1_val_weight", 0.1d)
2) What is the purpose, and correct usage, of " __.V() "?
g.V().property("prop1", "prop1_val")
.as_("a").V().property("prop2", "prop2_val")
.as_("b").addE("some_relationship")
.property("prop1_val_weight", 0.1d)
# AND THEN:
.from_("a").to("b")
# VERSUS:
.from_(__.V("a")).to(__.V("b"))
3) What are the differences between using "property" vs. "properties":
g.V().property("prop1", "prop1_val").as_("a")
# VERSUS:
g.V().properties("prop1", "prop1_val").as_("a")
# REST OF THE TRAVERSAL:
.V().property("prop2", "prop2_val").as_("b")
.addE("some_relationship")
.property("prop1_val_weight", 0.1d)
.from_("a").to("b")
4) What happens when there is no ".to()" vertex/vertices specified, and in this case, also using " __.V() " :
g.V().property("prop1", "prop1_val").as_("a")
.V().property("prop2", "prop2_val").as_("b")
.addE("some_relationship").to(__.V()
.has("prop2", "prop2_val"))
5) What are the reasons for adding " .profile()" at the end of a traversal:
g.V('Alice').as_('v').V('Bob').coalesce(inE('spokeWith')
.where(outV().as_('v')).addE('spokeWith')
.property('date', 'xyz').from_('v'))
.profile()
6) What is the correct usage, and in general the added advantage, of using the "coalesce" step while adding edges, like it's being used in the traversal at 5 ^^ ?
7) And a few general questions:
- what is the advantage of also looking for the label, e.g. " g.V().has("LABEL1", "prop1", "prop1_val").as_("a") [etc.]"
- after assigning a traversal to a variable (eg. " t = g.V() ... " in several steps, is it sufficient to then only once, at the end, call "t.iterate()" or should this be done each time?
- at which point in a script should one call "tx.commit()": is calling it only once, at the end of several traversals, sufficient?