[英]Is there a Neo4j A* Cypher query?
I'm currently using Neo4j's built-in Dijkstra to find the shortest path and it works. 我目前正在使用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
I want to be able to use A* algorithm as my nodes have Latitude and Longitude. 我希望能够使用A *算法,因为我的节点具有纬度和经度。 Is there a Cypher query for that?
是否有Cypher查询?
There is an A* algorithm in the APOC library's graph algorithms. APOC库的图算法中有一个A *算法。
run A* with relationship property name as cost function
使用关系属性名称作为成本函数运行A *
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
使用关系属性名称作为成本函数运行A *
apoc.algo.aStar(
startNode, endNode, 'KNOWS|<WORKS_WITH|IS_MANAGER_OF>',
{weight:'dist',default:10, x:'lon',y:'lat'}
) YIELD path, weight
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.