是否有 Neo4j A* Cypher 查询?

Is there a Neo4j A* Cypher query?

我目前正在使用 Neo4j 的内置 Dijkstra 来查找最短路径并且它有效。

START start=node(123), end=node(203454)
MATCH p=(start)-[:CONNECTS]->(end)
RETURN p as shortestPath,
REDUCE(distance=0, r in relationships(p) | distance+r.distance) AS totalDistance
ORDER BY totalDistance ASC
LIMIT 1

我希望能够使用 A* 算法,因为我的节点具有纬度和经度。有 Cypher 查询吗?

APOC library's图算法中有一个A*算法。

run A* with relationship property name as cost function

apoc.algo.aStar(
    startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>', 
    'distance','lat','lon'
) YIELD path, weight

run A* with relationship property name as cost function

apoc.algo.aStar(
  startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>',
  {weight:'dist',default:10, x:'lon',y:'lat'}
) YIELD path, weight