我正试图为纽约地铁实施一个简单的图表数据库。
共有493个带标签的停靠点:STOP和属性{name:"停止名称"},例如:
(n:STOP {name:"Van Cortlandt Park - 242 St"}) -[:DIRECT {dist:0.5}]-> (m:STOP {name:"238 St"})
共有566个关系[:DIRECT {dist:...}]
我想要得到的是一个节点列表和它们之间的总和(dist),从特定的停止开始,只返回具有一定总和(dist)的那些节点,cypher查询在我完成时运行完美限制关系数量,例如:
match p=(n:STOP {name:"Van Cortlandt Park - 242 St"})-[:DIRECT*1..10]-(m:STOP)
WITH n,m,
reduce(acc=0, x in relationships(p)| acc + x.dist) as x
WHERE x < 5
return n.name, m.name, x
limit 10
当我指定时会出现问题 - [:DIRECT *] - 大约10分钟后,查询几乎失败并出现未知错误
以下是具有限制的查询的分析:
==> +--------------------------------------------------------------------------------+
==> | n.name | m.name | x |
==> +--------------------------------------------------------------------------------+
==> | "Van Cortlandt Park - 242 St" | "238 St" | 0.33 |
==> | "Van Cortlandt Park - 242 St" | "231 St" | 0.78 |
==> | "Van Cortlandt Park - 242 St" | "Marble Hill - 225 St" | 1.1800000000000002 |
==> | "Van Cortlandt Park - 242 St" | "215 St" | 1.6400000000000001 |
==> | "Van Cortlandt Park - 242 St" | "207 St" | 2.02 |
==> | "Van Cortlandt Park - 242 St" | "Dyckman St" | 2.47 |
==> | "Van Cortlandt Park - 242 St" | "191 St" | 2.89 |
==> | "Van Cortlandt Park - 242 St" | "181 St" | 3.3400000000000003 |
==> | "Van Cortlandt Park - 242 St" | "168 St - Washington Hts" | 4.04 |
==> | "Van Cortlandt Park - 242 St" | "157 St" | 4.5600000000000005 |
==> +--------------------------------------------------------------------------------+
==> 10 rows
==>
==> ColumnFilter(0)
==> |
==> +Slice
==> |
==> +Extract(0)
==> |
==> +Filter(0)
==> |
==> +ColumnFilter(1)
==> |
==> +Extract(1)
==> |
==> +ExtractPath
==> |
==> +Filter(1)
==> |
==> +TraversalMatcher
==>
==> +------------------+------+--------+-------------+--------------------------------+
==> | Operator | Rows | DbHits | Identifiers | Other |
==> +------------------+------+--------+-------------+--------------------------------+
==> | ColumnFilter(0) | 10 | 0 | | keep columns n.name, m.name, x |
==> | Slice | 10 | 0 | | { AUTOINT3} |
==> | Extract(0) | 10 | 40 | | n.name, m.name |
==> | Filter(0) | 10 | 0 | | x < { AUTOINT2} |
==> | ColumnFilter(1) | 10 | 0 | | keep columns n, m, x |
==> | Extract(1) | 10 | 110 | | x |
==> | ExtractPath | 10 | 0 | p | |
==> | Filter(1) | 10 | 10 | | hasLabel(m:STOP(4)) |
==> | TraversalMatcher | 10 | 45 | | m, UNNAMED52, m |
==> +------------------+------+--------+-------------+--------------------------------+
谢谢!