![](/img/trans.png)
[英]Quickest way to find shortest paths from origin to all destinations in a directed weighted graph
[英]what is the best way to get all pair shortest path in very large scale weighted and directed graph?
我試圖在非常大的比例圖中找到所有對的最短路徑。 我試過 floyd-warshall 但它不夠快,因為圖表的規模非常大。 頂點數超過 100k。 也許需要一個多星期......實際上我不需要所有的路徑。 我只需要最長的那個。
您可能想要實施Hagerup的全對最短路徑變體。 O(nm + n^2 log log n)
的時間界限可能比 Floyd–Warshalls O(n^3)
好得多,這取決於你的圖有多少條邊。
您也可以設置 Neo4j 並使用它來計算該路徑: https://neo4j.com/docs/graph-data-science/current/alpha-algorithms/all-pairs-shortest-path/#algorithm-所有對最短路徑樣本
CALL gds.alpha.allShortestPaths.stream({
nodeProjection: 'Loc',
relationshipProjection: {
ROAD: {
type: 'ROAD',
properties: 'cost'
}
},
relationshipWeightProperty: 'cost'
})
我不知道,但根據語法,您可能只能從 stream 到 select 的特定路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.