Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用灯泡通过groovy脚本进行Gremlin查询_Python_Titan_Gremlin_Bulbs - Fatal编程技术网

Python 使用灯泡通过groovy脚本进行Gremlin查询

Python 使用灯泡通过groovy脚本进行Gremlin查询,python,titan,gremlin,bulbs,Python,Titan,Gremlin,Bulbs,我正试图找到一种更好的方法,通过python库bulls使用gremlin查询titan 我有一棵简单的树 n0 / \ / \ n1 n2 / \ \ n3 n4 n5 我想得到n4和边:e[n0->n1]=>e1,e[n1->n4]=>e2直到n4。所以在这个例子中,我想要[e1,e2,n4] 在执行查询之前,我知道节点的所有索引。在此示例中,node_id=['ddbe4d52e7034ffeb17

我正试图找到一种更好的方法,通过python库
bulls
使用
gremlin
查询
titan

我有一棵简单的树

       n0
     /   \
   /       \
  n1       n2
 /  \       \
n3  n4      n5
我想得到
n4
和边:
e[n0->n1]=>e1
e[n1->n4]=>e2
直到
n4
。所以在这个例子中,我想要
[e1,e2,n4]

在执行查询之前,我知道节点的所有索引。在此示例中,
node_id=['ddbe4d52e7034ffeb17c9426fc1484af',754d5e84daad4140ba93cb10ce00cde0','7b284543b44fcc94e69d7930ffa996']

有了这些信息,我可以构建这个查询,我觉得这个查询相当长且重复

g.V('nid', 'ddbe4d52e7034ffeb17c9426fc1484af').out
    .has('nid', '754d5e84daad4140ba93cb10ce00cde0').out
    .has('nid', '7b2848543b444fcc94e69d7930ffa996')
这只给出了最后一个节点。我仍在试图找出
sideAffect
这个东西,
gremlin
必须返回我需要的边缘

我知道我可以创建自定义脚本并使用那些彻底的
gremlin
,但我对所有这些东西都很陌生,因此非常感谢您的帮助

我要找的东西的伪代码

def get_node(nodes) {
    edges = []
    for node in nodes:
        get first node
        find edge that goes to second node
        edges.append(edge)
    return edges + last node
}
另外,如果有人有一个关于gremlin/groovy的好教程,那会很有帮助


谢谢

您可以找到路径。尝试:

g.V('nid', 'ddbe4d52e7034ffeb17c9426fc1484af').outE.inV
.has('nid', '754d5e84daad4140ba93cb10ce00cde0').outE.inV
.has('nid', '7b2848543b444fcc94e69d7930ffa996').path
这将为您提供一个包含以下内容的列表:

[startVertex, startIntermediateEdge, intermediateVertex, intermediateTargetEdge, targetVertex]