Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to solve the problem of inaccurate neo4j allshortestpaths query path

Shulou Source: shulou.com Published: 2022-06-02 07:28:49 10月01日 Update

This article introduces the relevant knowledge of "how to solve the problem of inaccurate neo4j allshortestpaths query path". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Basic grammar

Everyone who uses the neo4j cypher query language knows that cypher provides two special functions for querying the shortest path, shortestPath and allShortestPath. You can also see the explanation of the function of the two functions in the grammar manual of cypher. As the name implies, allShortestPath should be able to query all the shortest paths within the specified number of layers between two nodes.

! [] (https://oscimg.oschina.net/oscnet/35be422f883669a866a2bcdd20386208534.jpg

Phenomenon in the real test found that allShortestPath will ignore the extra longer path between two points when there is a short path between two points. It is shown as follows: there are three paths A, B and C between Yang Zi and Lin Xinru. Allshortestpaths can only find An and B (the same length), and the longer C path is ignored.

Recommendations:

If you want to get all the paths within the specified number of layers between two points, it is recommended to use relational queries directly. (note that there are performance problems when the amount of data is large)

MATCH p = (N1 {thingId: "5d47e1412227360001b516a7"})-[rq0.6]-(N2 {thingId: "5d47e1432227360001b516bb"}) RETURN p "how to solve the problem of inaccurate neo4j allshortestpaths query paths" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Path query question two between content function suggestion situation more knowledge grammar practical special larger as the name implies successful learning next function dilemma Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Shulou Information Shulou Tech Info macOS vpn