Gremlin, How to add edge to existing vertex in gremlin-python

ぐ巨炮叔叔 提交于 2019-12-12 05:26:52

问题


I am trying to add edge to an existing node in gremlin-python. But graph traversal(g) object do not have addE method and vertex do not have addEdge method.


回答1:


You can do it with a mid-traversal V():

>>> vFrom = g.V(1).next()
>>> vTo = g.V(6).next()
>>> g.V(vTo).as_('t').V(vFrom).addE("knows").to("t").toList()
[e[13][1-knows->6]]

I did learn that there is a bug that prevents this approach that uses withSideEffect() in TinkerPop 3.2.4:

>>> g.withSideEffect("t",vTo).V(vFrom).addE("knows").to("t").toList()

I created an issue to help track the bug.



来源:https://stackoverflow.com/questions/44200374/gremlin-how-to-add-edge-to-existing-vertex-in-gremlin-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!