[英]juHow to find % of missing values which are greater than 1 or 0 in python
[英]gremlin-python-gets nodes with greater than two edges
如果您可以包含一個代碼片段,顯示您使用的導入以及查詢,那將會很有幫助。 在你的 Python 代碼中,你記得導入這個類嗎?
from gremlin_python.process.graph_traversal import __
我可以使用我的圖表之一毫無問題地運行您的查詢
g.V().hasLabel('airport').where(__.out().count().is_(P.gte(2))).count().next()
如果您沒有該導入,您將看到與您所看到的類似的錯誤。
在此位置使用 gremlin-python 時,有一個最常用的導入列表
編輯添加:
正如斯蒂芬在下面的評論中指出的那樣,您只需要知道是否至少有兩個傳出邊緣,您就可以通過添加limit
步驟來減少查詢引擎必須執行的工作(某些優化器可能不需要這樣做)。
g.V().hasLabel('airport').where(__.out().limit(2).count().is_(P.gt(1))).count().next()
from gremlin_python.structure.graph import Graph
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
graph_db_uri = 'ws://localhost:8182/gremlin'
g = graph.traversal().withRemote(DriverRemoteConnection(graph_db_uri,'g'))
c=g.V().hasLabel('node_name').count().next()
print(c)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.