Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用cypher在Neo4j中找不到最亮的路径_Neo4j_Cypher - Fatal编程技术网

用cypher在Neo4j中找不到最亮的路径

用cypher在Neo4j中找不到最亮的路径,neo4j,cypher,Neo4j,Cypher,我试图在下图中找到从节点a到e的最轻路径: 结果应该是13: a -> b: 1 b -> c: 3 c -> d: 4 d -> e: 5 (take lighter edge) ---------- 13 我尝试了几个例子,例如,但找不到正确的查询 MATCH (start:LocationNode{name:'a'}), (end:LocationNode{name:'e'}) CALL algo.shortestPath(start, e

我试图在下图中找到从节点a到e的最轻路径:

结果应该是13:

a -> b:  1
b -> c:  3
c -> d:  4
d -> e:  5 (take lighter edge)
----------
        13
我尝试了几个例子,例如,但找不到正确的查询

MATCH (start:LocationNode{name:'a'}), (end:LocationNode{name:'e'})
CALL algo.shortestPath(start, end, 'weight',{write:true,writeProperty:'sssp'})
YIELD writeMillis,loadMillis,nodeCount, totalCost
RETURN writeMillis,loadMillis,nodeCount,totalCost
导致

╒═════════════╤════════════╤═══════════╤═══════════╕
│"writeMillis"│"loadMillis"│"nodeCount"│"totalCost"│
╞═════════════╪════════════╪═══════════╪═══════════╡
│3            │3           │5          │12.0       │
└─────────────┴────────────┴───────────┴───────────┘
╒═════════════╤════════════╤═══════════╤═══════════╕
│"writeMillis"│"loadMillis"│"nodeCount"│"totalCost"│
╞═════════════╪════════════╪═══════════╪═══════════╡
│3            │19          │4          │14.0       │
└─────────────┴────────────┴───────────┴───────────┘

导致

╒═════════════╤════════════╤═══════════╤═══════════╕
│"writeMillis"│"loadMillis"│"nodeCount"│"totalCost"│
╞═════════════╪════════════╪═══════════╪═══════════╡
│3            │3           │5          │12.0       │
└─────────────┴────────────┴───────────┴───────────┘
╒═════════════╤════════════╤═══════════╤═══════════╕
│"writeMillis"│"loadMillis"│"nodeCount"│"totalCost"│
╞═════════════╪════════════╪═══════════╪═══════════╡
│3            │19          │4          │14.0       │
└─────────────┴────────────┴───────────┴───────────┘
类似以下的其他查询甚至不会返回任何内容:

MATCH p=(LocationNode{name:'a'})-[:CONNECTED_TO*]->(LocationNode{name:'e'})
RETURN p as shortestPath,
REDUCE(weight=0, r in relationships(p) | weight+r.weight) AS totalDistance
我希望看到一个返回“13”作为解决方案并理想地显示所选路径的查询,如下所示:

我怎样才能做到这一点

非常感谢。

此查询:

MATCH p=(a:LocationNode{name:'a'})-[:CONNECTED_TO*]->(e:LocationNode{name:'e'})
WITH p, REDUCE(s=0, r IN RELATIONSHIPS(p) | s + r.weight) AS totalWeight
RETURN p, totalWeight
ORDER BY totalWeight
LIMIT 1
返回此结果:

╒══════════════════════════════════════════════════════════════════════╤═════════════╕
│"p"                                                                   │"totalWeight"│
╞══════════════════════════════════════════════════════════════════════╪═════════════╡
│[{"name":"a"},{"weight":1},{"name":"b"},{"name":"b"},{"weight":3},{"na│13           │
│me":"c"},{"name":"c"},{"weight":4},{"name":"d"},{"name":"d"},{"weight"│             │
│:5},{"name":"e"}]                                                     │             │
└──────────────────────────────────────────────────────────────────────┴─────────────┘
在neo4j浏览器中,如果禁用浏览器设置窗格底部的选项(可通过单击左侧面板中的齿轮图标来显示),则可视化将为:


非常感谢你!您可能知道该查询中使用的是哪种算法吗?迪克斯特拉,A*。。。?