我正在关注本教程:
https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-python.html
如何添加一个节点,然后检索相同的节点?
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
remoteConn = DriverRemoteConnection('wss://your-neptune-endpoint:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)
print(g.V().limit(2).toList())
remoteConn.close()
以上所有操作现在是在检索2个节点吗?
答案 0 :(得分:1)
如果要添加一个顶点,然后返回有关该顶点的信息(假设您没有提供自己的ID),可以执行类似的操作
newId = g.addV("mylabel").id().next()