shortest-path

“Bidirectional Dijkstra” by NetworkX

微笑、不失礼 提交于 2019-11-30 14:30:49
I just read the NetworkX implementation of Dijkstra's algorithm for shortest paths using bidirectional search (at this ). What is the termination point of this method? I'm going to base this on networkx's implementation. Bidirectional Dijkstra stops when it encounters the same node in both directions - but the path it returns at that point might not be through that node. It's doing additional calculations to track the best candidate for the shortest path. I'm going to base my explanation on your comment (on this answer ) Consider this simple graph (with nodes A,B,C,D,E). The edges of this

Fastest implementation for All-pairs shortest paths problem?

孤街醉人 提交于 2019-11-30 13:50:10
I have a weighted graph 30k nodes 160k edges, no negative weights. I would like to compute all the shortest paths from all the nodes to the others. I think I cannot assume any particular heuristics to simplify the problem. I tried to use this Dijkstra C implementation http://compprog.wordpress.com/2007/12/01/one-source-shortest-path-dijkstras-algorithm/ , that is for a single shortest path problem, calling the function dijkstras() for all my 30 nodes. As you can imagine, it takes ages. At the moment I don't have the time to write and debug the code by myself, I have to compute this paths as

how to save shortest path in dijkstra algorithm

风流意气都作罢 提交于 2019-11-30 08:26:41
问题 So first let's define Dijkstra algorithm: Dijkstra's algorithm finds single-source shortest paths in a directed graph with non-negative edge weights. I want to know how can I save the shortest path form s to t with Dijkstra algorithm. I searched on google, but I couldn't find anything particular; I also changed Dijkstra algorithm, but I could't get any answer. How can I save the shortest path from s to t with Dijkstra ? I know my question is basic and unprofessional, but any help would be

Dijkstra algorithm with min-priority queue

寵の児 提交于 2019-11-30 01:12:08
问题 I'm trying to implement the dijkstra algorithm with priority queue, but I can't understand how it works. I read many guide on the web but I can't understand this algorithm at all. My question are: what is the priority for each node? I think that it is the weight of the incoming edge with minimun value, but I'm not sure. Is this true? Second question, when I extract the root of the queue, how works if this node is not adjacency with no one of the visited nodes? 回答1: You should use priority

“Bidirectional Dijkstra” by NetworkX

百般思念 提交于 2019-11-29 21:24:06
问题 I just read the NetworkX implementation of Dijkstra's algorithm for shortest paths using bidirectional search (at this). What is the termination point of this method? 回答1: I'm going to base this on networkx's implementation. Bidirectional Dijkstra stops when it encounters the same node in both directions - but the path it returns at that point might not be through that node. It's doing additional calculations to track the best candidate for the shortest path. I'm going to base my explanation

Fastest implementation for All-pairs shortest paths problem?

末鹿安然 提交于 2019-11-29 19:42:21
问题 I have a weighted graph 30k nodes 160k edges, no negative weights. I would like to compute all the shortest paths from all the nodes to the others. I think I cannot assume any particular heuristics to simplify the problem. I tried to use this Dijkstra C implementation http://compprog.wordpress.com/2007/12/01/one-source-shortest-path-dijkstras-algorithm/, that is for a single shortest path problem, calling the function dijkstras() for all my 30 nodes. As you can imagine, it takes ages. At the

Finding shortest values between the cities in a dataframe

无人久伴 提交于 2019-11-29 18:05:48
I have a dataframe with cities and distance between other cities from each city. My dataset looks like, df, From City City A City B City C City D City A 2166 577 175 City B 2166 1806 2092 City C 577 1806 653 City D 175 2092 653 im planning to visit all the cities, I am trying to find in which order by cities I can travel with the shortest distance. I want to end with a starting position. start point and end point should be same. Is there a way to find this shortest distance across all the cities, or any other approach is available. please help. 来源: https://stackoverflow.com/questions/50196539

Shortest path in 2d arrays

痴心易碎 提交于 2019-11-29 11:31:10
*...*..D .G..*..... **...**. .S....*. ........ ...G**.. ........ .G..*... Here is 2d array where S- Source D-Destination G-Point must be visited ." . "Free paths "*"Block Paths Can you help me which would be the efficient algorithm to find the length of shortest pathi in java Only Horizontal and Vertical movements are possiable To find the shortest distance from start point to all other points in the map, you can use a BFS . Sample code: public void visit(String []map , Point start){ int []x = {0,0,1,-1};//This represent 4 directions right, left, down , up int []y = {1,-1,0,0}; LinkedList

How do I find the shortest path that covers all nodes in a directed cyclic graph?

て烟熏妆下的殇ゞ 提交于 2019-11-29 07:29:36
I need an example of the shortest path of a directed cyclic graph from one node (it should reach to all nodes of the graph from a node that will be the input). Please if there is an example, I need it in C++, or the algorithm. EDIT: Oops, misread the question. Thanks @jfclavette for picking this up. Old answer is at the end. The problem you're trying to solve is called the Travelling salesman problem . There are many potential solutions , but it's NP-complete so you won't be able to solve for large graphs. Old answer: What you're trying to find is called the girth of a graph. It can be solved

how to save shortest path in dijkstra algorithm

我们两清 提交于 2019-11-29 06:43:56
So first let's define Dijkstra algorithm: Dijkstra's algorithm finds single-source shortest paths in a directed graph with non-negative edge weights. I want to know how can I save the shortest path form s to t with Dijkstra algorithm. I searched on google, but I couldn't find anything particular; I also changed Dijkstra algorithm, but I could't get any answer. How can I save the shortest path from s to t with Dijkstra ? I know my question is basic and unprofessional, but any help would be appreciated. Thanks for considering my question. If you look at the pseudocode from the Wikipedia link you