我正在尝试将count和distinct与理解列表结合起来,并不断出错。
我认为这可以解释我想做的事情,尽管我知道它不起作用:
Match (n) WHERE n.id={id}
RETURN n {.id, ems: [(n)<-[:LOTS_OF_PATHS*]-()<-[:EVEN_MORE_PATHS*]-(m) | id: distinct m.id, count: count(distinct m)]}
也尝试过在其中收集一些东西
Match (n) WHERE n.id={id}
RETURN n {.id, ems: [(n)<-[:LOTS_OF_PATHS*]-()<-[:EVEN_MORE_PATHS*]-(m) | collect(distinct m {id:m.id}), count: count(distinct m)]}
我实际上是在收集理解列表,理想情况下,每个数组中都不要重复,理想情况下,collects之和中不要重复。
Match (n) WHERE n.id={id}
RETURN n {.id, collect([(n)<-[:LOTS_OF_PATHS*]-()<-[:EVEN_MORE_PATHS*]-(m) | distinct m.id])+ collect([(n)<-[:OTHER_PATHS*]-()<-[:MORE_PATHS*]-(o) | distinct o.id]) as distinct_ems_and_os}
计数不那么重要,因为我可以对数组进行计数,但希望更好地理解它。
答案 0 :(得分:0)
此查询(不使用相当有限的模式理解)可能对您有用:
import cv2
video_capture = cv2.VideoCapture(0)
# Check success
if not video_capture.isOpened():
raise Exception("Could not open video device")
# Read picture. ret === True on success
ret, frame = video_capture.read()
# Close device
video_capture.release()
注意:variable-length relationships具有指数复杂度。您可能需要在跳数上设置一个合理的上限,以免耗尽内存或延长执行时间。