我如何在 gremlin 控制台上将查询写入 return 这些具有平行边的顶点对?
how can i write the query on gremlin console to return the pair vertices these have the parallel edge?
我想将此密码查询转换为 gremlin。
(n:人)-[:朋友]->(t:人)-[:朋友]->(n:人)
谢谢
使用航线数据集,一种方法是使用如下 cyclicPath
步骤。
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path()
==>[v[44],e[5019][44-route->8],v[8],e[3975][8-route->44],v[44]]
==>[v[44],e[5020][44-route->13],v[13],e[4158][13-route->44],v[44]]
==>[v[44],e[5021][44-route->20],v[20],e[4387][20-route->44],v[44]]
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path().by('code').by()
==>[SAF,e[5019][44-route->8],DFW,e[3975][8-route->44],SAF]
==>[SAF,e[5020][44-route->13],LAX,e[4158][13-route->44],SAF]
==>[SAF,e[5021][44-route->20],PHX,e[4387][20-route->44],SAF]
==>[SAF,e[5022][44-route->31],DEN,e[4736][31-route->44],SAF]
==>[v[44],e[5022][44-route->31],v[31],e[4736][31-route->44],v[44]]
或者如果您只想要边缘 ID
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path().by('code').by(id)
==>[SAF,5019,DFW,3975,SAF]
==>[SAF,5020,LAX,4158,SAF]
==>[SAF,5021,PHX,4387,SAF]
==>[SAF,5022,DEN,4736,SAF]
编写此查询的另一种方法涉及 where
步骤
gremlin> g.V('44').as('a').outE().inV().outE().inV().where(eq('a')).path().by('code').by()
==>[SAF,e[5019][44-route->8],DFW,e[3975][8-route->44],SAF]
==>[SAF,e[5020][44-route->13],LAX,e[4158][13-route->44],SAF]
==>[SAF,e[5021][44-route->20],PHX,e[4387][20-route->44],SAF]
==>[SAF,e[5022][44-route->31],DEN,e[4736][31-route->44],SAF]
我想将此密码查询转换为 gremlin。
(n:人)-[:朋友]->(t:人)-[:朋友]->(n:人)
谢谢
使用航线数据集,一种方法是使用如下 cyclicPath
步骤。
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path()
==>[v[44],e[5019][44-route->8],v[8],e[3975][8-route->44],v[44]]
==>[v[44],e[5020][44-route->13],v[13],e[4158][13-route->44],v[44]]
==>[v[44],e[5021][44-route->20],v[20],e[4387][20-route->44],v[44]]
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path().by('code').by()
==>[SAF,e[5019][44-route->8],DFW,e[3975][8-route->44],SAF]
==>[SAF,e[5020][44-route->13],LAX,e[4158][13-route->44],SAF]
==>[SAF,e[5021][44-route->20],PHX,e[4387][20-route->44],SAF]
==>[SAF,e[5022][44-route->31],DEN,e[4736][31-route->44],SAF]
==>[v[44],e[5022][44-route->31],v[31],e[4736][31-route->44],v[44]]
或者如果您只想要边缘 ID
gremlin> g.V('44').outE().inV().outE().inV().cyclicPath().path().by('code').by(id)
==>[SAF,5019,DFW,3975,SAF]
==>[SAF,5020,LAX,4158,SAF]
==>[SAF,5021,PHX,4387,SAF]
==>[SAF,5022,DEN,4736,SAF]
编写此查询的另一种方法涉及 where
步骤
gremlin> g.V('44').as('a').outE().inV().outE().inV().where(eq('a')).path().by('code').by()
==>[SAF,e[5019][44-route->8],DFW,e[3975][8-route->44],SAF]
==>[SAF,e[5020][44-route->13],LAX,e[4158][13-route->44],SAF]
==>[SAF,e[5021][44-route->20],PHX,e[4387][20-route->44],SAF]
==>[SAF,e[5022][44-route->31],DEN,e[4736][31-route->44],SAF]