我目前正在使用py2neo
来使用使用最短路径的查询,neo4j
代码是:
MATCH p=(c:Ciudad)-[*]-(l:Ciudad)
WHERE c.nombre = '%s' and l.nombre = '%s'
RETURN p as shortestPath, reduce(precio=0, r in relationships(p) | precio+r.precio) AS totalPrecio
ORDER BY totalPrecio ASC LIMIT 1;
当我在web上使用它时,它给出了Node 1- Relation - Node 2的列表,但当我使用以下命令执行此操作时:
string= "MATCH p=(c:Ciudad)-[*]-(l:Ciudad)
WHERE c.nombre = '%s' and l.nombre = '%s'
RETURN p as shortestPath, reduce(precio=0, r in relationships(p) | precio+r.precio) AS totalPrecio
ORDER BY totalPrecio ASC LIMIT 1;" %(salida, llegada)
n = graph.run(string)
shortestPath
只有关系,没有节点。
有人知道如何在网络上获得相同的结果吗?
https://stackoverflow.com/questions/56969568
复制相似问题