我使用gremlin控制台创建了一个图形
gremlin> ConfiguredGraphFactory.graphNames
==>MYGRAPH
gremlin> ConfiguredGraphFactory.getConfiguration('MYGRAPH')
==>storage.backend=cql
==>graph.graphname=MYGRAPH
==>storage.hostname=127.0.0.1
==>Template_Configuration=false
gremlin> g.V().properties()
==>vp[name->SFO]
==>vp[country->USA]
==>vp[name->ALD]
==>vp[country->IND]
==>vp[name->BLR]
==>vp[country->IND]
gremlin>
Run Code Online (Sandbox Code Playgroud)
我想使用gremlin-python连接MYGRAPH.有人可以告诉我如何使用gremlin-python访问名为"MYGRAPH"的图形.
提前致谢...
我正在使用Gremlin-Python Client查询带有janusgraph后端的Gremlin Server。
运行以下查询:
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
sg = g.E().subgraph('a').cap('a').next()
Run Code Online (Sandbox Code Playgroud)
查询返回一个子图,其中包含边和顶点的列表。
我在服务器上配置了以下序列化器
serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何配置gremlin-server和示例代码以返回完全填充的子图?
根据Stephen的反馈更新了测试用例
# DB: Janusgraph with Opensource Cassandra storage backend
# Data: v[41427160]--reports_to-->v[36712472]--reports_to-->v[147841048]
# Objective: get subgraph detached to python client with all properties of the vertex and edges
(py365)$ pip list | grep gremlinpython
gremlinpython 3.3.4 …Run Code Online (Sandbox Code Playgroud) 当尝试将我在 Gremlin CLI 中编写和测试的查询转换为 gremlin-python 时,我unexpected token 'as'的表达式遇到错误.as('foo')。as使用 gremlin-python 时如何使用 Gremlin关键字?
我正在尝试从头开始创建一个在 graphexp 中可视化的图表,但我正在努力理解匿名遍历的概念以及如何创建它们
我正在使用 python 3.9 和 gremlinpython 3.5.1
from gremlin_python.process.anonymous_traversal import traversal
self.g = traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin', 'g'))
Run Code Online (Sandbox Code Playgroud)
statics.load_statics(globals())
Run Code Online (Sandbox Code Playgroud)
def _add_vertex(self, name):
return self.g.V().has('name', name).fold().coalesce(unfold(), addV().property('name',name)).next()
Run Code Online (Sandbox Code Playgroud)
def _add_edge(self, v1, v2, weight, label):
return self.g.V(v1).as_("fromVertex").V(v2).coalesce(inE(label).where(outV().as_(
"fromVertex")), addE(label).property("weight", weight).from_("fromVertex")).next()
Run Code Online (Sandbox Code Playgroud)
但是当我点击一个顶点时,我在 graphexp 中遇到了这个错误
Error retrieving data
The child traversal of [GraphStep(vertex,[696560]), PropertyMapStep(value)] was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal
Run Code Online (Sandbox Code Playgroud)
该文档总体不错,但对于匿名遍历部分没有太大帮助。那么如何使用这种方法生成匿名子遍历呢?它的真正含义是什么?
我知道图形笔记本项目允许使用魔法命令提交 Gremlin 查询。但是,有时我需要在常规 Jupyter 笔记本单元中使用 Python 进行编码并使用代码连接到服务器。如果使用 Gremlin Python 3.5.2 客户端,我尝试执行以下操作:
server = '<your server endpoint goes here>'
port = 8182
endpoint = f'wss://{server}:{port}/gremlin'
connection = DriverRemoteConnection(endpoint,'g')
g = traversal().withRemote(connection)
Run Code Online (Sandbox Code Playgroud)
由于 Jupyter 事件循环已在运行,因此会引发错误。
有没有解决的办法?
gremlin tinkerpop amazon-neptune gremlinpython graph-notebook
我目前正在使用 gremlin-python 来研究图表。我想获得具有两个以上出边的所有顶点。我正在使用匿名遍历根据边缘计数过滤掉用户,但下面是我得到的错误。
AttributeError: 'list' 对象没有属性 'out'
我对此很陌生,不确定我在这里做错了什么。这是可用的有限 gremlin-python 教程/文档中描述的方式。
我正在尝试从 Python 代码内部对 AWS Neptune 数据库运行 Gremlin 查询,并希望将返回的数据存储到 Python 列表中。这对于简单的 Gremlin 查询工作正常,但一些更复杂的查询似乎有问题。
下面是代码,第一个 Gremlin 查询工作正常,但第二个不行。该节点不存在,因此可以在不导入任何数据的情况下进行尝试。
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://sdm-neptune-db-instance-1.cduuicw2rgrv.us-east-1.neptune.amazonaws.com:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)
cust_List=g.V('AZ50K115E39AX').hasLabel('tp21tpcust').count().toList()
for p in cust_List:
print('Data Fetched: ' + str(p))
cust_List=g.V('XXXXXXXX').hasLabel('tp21tpcust').local(__.repeat(__.out().simplePath()).until(__.not_(__.out())).path().by(id).limit(100)).local(__.unfold().union(__.limit(1),__.tail()).fold()).dedup().toList()
for p in cust_List:
print('Data Fetched' + p)
remoteConn.close()
Run Code Online (Sandbox Code Playgroud)
这是错误,任何指导将不胜感激
Data Fetched: 1
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud)