Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of inaccurate neo4j allshortestpaths query path

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report