簡體   English   中英

TinkerPop:按邊數過濾

[英]TinkerPop: Filter by Edge count

樣本數據: TinkerPop Modern

簡介:我想找到創建了2個軟件的人。

我從基礎開始,並正確計算

g.V().hasLabel("Person").as("from" ,"to1" )
.repeat(bothE().as("e1").otherV().as("to1").dedup("from", "to1")).times(1)
.emit(filter(hasLabel("Software"))).hasLabel("Software")
.group().by(select("from").by("name")).by(count()).as("c")

結果:

>> {'Marko': 1, 'Peter': 1, 'Josh': 2}

所以我嘗試應用過濾器,但它不起作用(即結果不正確),我嘗試了:

g.V().hasLabel("Person").as("from")
.repeat(bothE().as("e1").otherV().as("to1").dedup("from", "to1")).times(1)
.filter(bothE().otherV().hasLabel("Software").count(local).is(eq(1)))
.dedup()
.values("name")

知道我做錯了什么嗎?


樣本數據:

在此輸入圖像描述

如果你只是需要邊緣計數的“人”頂點,我真的不明白為什么你需要所有的repeat()基礎設施。 只是:

gremlin> g.V().hasLabel('person').
......1>   filter(outE('created').limit(2).count().is(2))
==>v[4]

您只需要計算傳出邊緣,因為架構是“創建”標簽僅連接到“軟件”,因此您不需要檢查“軟件”頂點標簽。 limit(2)盡快退出邊迭代,但不是在您嘗試計算的2條邊之前。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM