Sri*_*esh 1 gremlin tinkerpop3
刚开始使用 gremlin。
打印出所有顶点值都很好
gremlin> g.V().values()
==>testing 2
==>Cash Processing
==>Sales
==>Marketing
==>Accounting
Run Code Online (Sandbox Code Playgroud)
我能够找到我的顶点之间的所有直接连接的路径。
gremlin> g.V().hasLabel('Process')
.repeat(both().simplePath())
.until(hasLabel('Process'))
.dedup().path()
==>[v[25],v[28]]
==>[v[25],v[26]]
==>[v[26],v[27]]
==>[v[26],v[25]]
Run Code Online (Sandbox Code Playgroud)
现在我试图打印出路径中的值,如 ['Sales', 'Accounting'] 而不是 [v[25],v[28]]
还没有想出办法
已经尝试过但失败了
展开:没有得到我的 1-1 映射
gremlin> gV().hasLabel('Process').repeat(both().simplePath()).until(hasLabel('Process')).dedup().path().unfold().values() = =>现金处理==>会计==>现金处理==>销售==>销售==>营销==>销售==>现金处理
路径似乎是不同的数据类型,不支持 .values() 函数
gremlin> gV().hasLabel('Process') .repeat(both().simplePath()) .until(hasLabel('Process')) .dedup().path().values()
org.apache.tinkerpop.gremlin.process.traversal.step.util.ImmutablePath 不能转换为 org.apache.tinkerpop.gremlin.structure.Element
尝试了以下谷歌搜索并没有得到答案
在这里找到了一个适用于 Java 的,但对我不起作用
l = []; gV(.....path().fill(l)
(但不能创建列表,不能设置只读属性:类列表:org.apache.tinkerpop.gremlin.structure.VertexProperty$Cardinality)
我在 Gremlin 控制台上运行它(运行 ./gremlin.sh)
您可以使用by step来调整路径内的元素。例如,通过提供valueMap(true)给by您的顶点标签和它们的ID得到顶点的性质,在一起:
gremlin> g.V().repeat(both().simplePath()).times(1).dedup().path().by(valueMap(true))
==>[[id:1,name:[marko],label:person,age:[29]],[id:3,name:[lop],lang:[java],label:software]]
==>[[id:1,name:[marko],label:person,age:[29]],[id:2,name:[vadas],label:person,age:[27]]]
==>[[id:1,name:[marko],label:person,age:[29]],[id:4,name:[josh],label:person,age:[32]]]
==>[[id:2,name:[vadas],label:person,age:[27]],[id:1,name:[marko],label:person,age:[29]]]
==>[[id:3,name:[lop],lang:[java],label:software],[id:6,name:[peter],label:person,age:[35]]]
==>[[id:4,name:[josh],label:person,age:[32]],[id:5,name:[ripple],lang:[java],label:software]]
Run Code Online (Sandbox Code Playgroud)
我使用了现代图,它是 TinkerPop 的玩具图之一,经常用于此类示例。您的输出看起来会有些不同,您可能想要使用除调制器以外valueMap(true)的其他东西by。该步骤本身的TinkerPop 文档path包含两个更高级的示例path().by(),您可能需要查看这些示例。
| 归档时间: |
|
| 查看次数: |
1770 次 |
| 最近记录: |