shortest-path

shortest path with one edge turn to zero

大憨熊 提交于 2019-12-05 02:24:40
问题 given an undirected weighted graph G , and two vertices: start vertex and end vertex what's the most efficient algorithm that finds the shortest path from start to end with ability to turn weight of exactly one edge to zero? EDIT: i know dijkstra algorithm , but as i said , situation is different in this problem: we're allowed to turn one edge to zero, i wanna know how solve this problem efficiently, actually , one way is turn edges weights to zero iteratively! and apply dijkstra algorithmin

Shortest One-Way Path Through Multiple Nodes

China☆狼群 提交于 2019-12-05 00:46:47
问题 I have a series of graph coordinates and I need to find the shortest one-way path through them all. I have no predetermined start/end but each point must only be touched once and returning to the optimal origin is NOT required. I've tried a couple TSP approaches, but they all seem to be based on returning to the origin at the end which gives terribly inefficient results in this case. Example 1, 13 3, 0 3, 7 2, 21 2, 11 3, 12 1, 19 3, 6 would resolve to 3, 0 3, 6 3, 7 3, 12 2, 11 1, 13 1, 19 2

Implementing Bidirectional A* Shortest Path Algorithm

人盡茶涼 提交于 2019-12-04 14:43:47
I am implementing a symmetric bidirectional A* shortest path algorithm, as mentioned in [Goldberg and Harrelson,2005] . This is only for understanding the algorithm, therefore I used the most basic version without any optimization steps. My problem is the bidirectional algorithm appears to scan almost two times the number of edges scanned in a uni-directional A* search on the test graph. Example: a s-t query on a road network using A* (left) and bidirectional A* (right). Nodes scanned by the forward and backward search are colored in red and green, respectively. The heuristic function is

FInding All Shortest Paths Between Two Vertices

大兔子大兔子 提交于 2019-12-04 12:54:32
Given a directed graph G=(V,E) , two vertices s , t and two weight functions w1 , w2 , I need to find the shortest path from s to t by w2 among all the shortest paths between s to t by w1 . First of all , how could I find all the shortest paths between two vertices s and t ? Dijkstra's algorithm helps us find shortest path from a vertex to to every other accessible vertex, is it possible to modify it in order to get all the shortest paths between two vertices? I will expand on comments to the question. The problem is, for some graphs, you can have an exponential number of shortest paths

Bellman-Ford: all shortest paths

蓝咒 提交于 2019-12-04 10:36:48
I've successfully implemented Bellman-Ford to find the distance of the shortest path when edges have negative weights/distances. I've not been able to get it to return all shortest paths (when there are ties for shortest). I managed to get all shortest paths (between a given pair of nodes) with Dijkstra. Is this possible with Bellman-Ford? (just want to know if I'm wasting my time trying) If you alter the second step of the Bellman-Ford algorithm a little bit you can achieve something very similar: for i from 1 to size(vertices)-1: for each edge uv in edges: // uv is the edge from u to v u :=

Go, Dijkstra : print out the path, not just calculate the shortest distance

倖福魔咒の 提交于 2019-12-04 08:56:34
Go, Dijkstra : print out the path, not just calculate the shortest distance. http://play.golang.org/p/A2jnzKcbWD I was able to find the shortest distance using Dijkstra algorithm, maybe not. The code can be found here. But it would be useless if I can't print out the path. With a lot of pointers going on, I can't figure out how to print out the final path that takes the least amount of weights. In short, how do I not only find the shortest distance, but also print out the shortest path on this given code? The link is here: http://play.golang.org/p/A2jnzKcbWD And the snippet of the code is

graph - Shortest path with Vertex Weight

不打扰是莪最后的温柔 提交于 2019-12-04 08:03:15
问题 Here is an excise: In certain graph problems, vertices have can have weights instead of or in addi- tion to the weights of edges. Let Cv be the cost of vertex v, and C(x,y) the cost of the edge (x, y). This problem is concerned with finding the cheapest path between vertices a and b in a graph G. The cost of a path is the sum of the costs of the edges and vertices encountered on the path. (a) Suppose that each edge in the graph has a weight of zero (while non-edges have a cost of ∞).Assume

Shortest path between raw geo coordinates and a node of a graph

久未见 提交于 2019-12-04 08:00:18
I have implemented a simple Dijkstra's algorithm for finding the shortest path on an .osm map with Java. The pathfinding in a graph which is created from an .osm file works pretty well. But in case the user's current location and/or destination is not a node of this graph (just raw coordinates) how do we 'link' those coordinates to the graph to make pathfinding work? The simple straightforward solution "find the nearest to the current location node and draw a straight line" doesn't seem to be realistic. What if we have a situation like on the attached picture? (UPD) The problem here is that

Find shortest path from Vertex u to v passing through a vertex w?

℡╲_俬逩灬. 提交于 2019-12-04 05:12:31
In a directed graph with non-negative edge weights I can easily find shortest path from u to v using dijkstra's. But is there any simple tweak to Dijkstra's so that I can find shortest path from u to v through a given vertex w. Or any other algorithm suggestions? Find the shortest path from u to w, then the shortest path from w to v. Find shortest path from u to w Find shortest path from w to v Then u->w->v is the shortest path. You can do it by running Dijkstra for two times, but you can also apply the Floyd-Warshall algorithm. Zach Langley This problem is NP-hard, so finding a polynomial

how to find the best three routes using A* algorithm

▼魔方 西西 提交于 2019-12-04 03:31:54
问题 In A* usually the result that you get is only one path. Is it possible though for a given origin and destination to have 3 recommended path according to A*? So the second returned is the second best path, and the third is the third best path.. I was thinking of maybe modifying the heuristic somehow to reflect this second and third best path.. What do you guys think? UPDATE: My implementation is in PHP and I am using a closed set. So if there's a way to do this, let me know. 回答1: This can be