shortest-path

Cluster growing of blobs

孤街醉人 提交于 2019-12-21 20:42:38
问题 Consider the following image which is from Mathworks: I have labelled the blobs with [L, num]= bwlabel(I); How do I connect all the blobs iteratively,i.e.start with one blob and find the nearest one to it.Consider the left-most two blobs, there can be many lines that can be drawn from many points of a blob to connect to the other blob, but the shortest one would be obtained by finding the pixel of a blob that is nearest to the other blob, find a similar pixel in the other blob and connect

FInding All Shortest Paths Between Two Vertices

我是研究僧i 提交于 2019-12-21 18:40:42
问题 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? 回答1: I will expand on comments

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

孤街浪徒 提交于 2019-12-21 10:57:08
问题 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? 回答1: Find the shortest path from u to w, then the shortest path from w to v. 回答2: 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

What is the purpose of the visited set in Dijkstra?

ⅰ亾dé卋堺 提交于 2019-12-21 09:07:21
问题 On the Wikipedia page for Dijkstra's algorithm, they mark visited nodes so they wouldn't be added to the queue again. However, if a node is visited then there can be no distance to that node that is shorter, so doesn't the check alt < dist[v] already account for visited nodes? Am I misunderstanding something about the visited set? for each neighbor v of u: alt := dist[u] + dist_between(u, v); // accumulate shortest dist from source if alt < dist[v] && !visited[v]: dist[v] := alt; // keep the

AStar - explanation of name

心不动则不痛 提交于 2019-12-21 07:16:32
问题 I am looking for an explanation why the AStar / A* algorithm is called AStar. All similar (shortest path problem) algorithms are often named like its developer(s), so what is AStar standing for? 回答1: There were algorithms called A1 and A2. Later, it was proved that A2 was optimal and in fact also the best algorithm possible, so he gave it the name A* which symbolically includes all possible version numbers. Source: In 1964 Nils Nilsson invented a heuristic based approach to increase the speed

Shortest Path For A Dag

*爱你&永不变心* 提交于 2019-12-21 05:28:16
问题 I have a graph with an s and t vertex that I need to find the shortest path between. The graph has a lot of special properties that I would like to capitalize on: The graph is a DAG (directed acyclic graph). I can create a topological sort in O(|V|) time, faster than the traditional O(|V + E|). Within the topological sort, s is the first item in the list and t is the last. I was told that once I have a topological sort of the vertices I could find the shortest path faster than my current

Can Dijkstra's Single Source Shortest Path Algorithm detect an infinite cycle in a graph?

荒凉一梦 提交于 2019-12-20 10:43:53
问题 So I came to this beautiful problem that asks you to write a program that finds whether a negative infinity shortest path exists in a directed graph. (Also can be thought of as finding whether a "negative cycle" exists in the graph). Here's a link for the problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=499 I successfully solved the problem by running Bellman Ford Algorithm twice by starting with any source in the graph. The second time I

Suggestions for KSPA on undirected graph

僤鯓⒐⒋嵵緔 提交于 2019-12-19 03:14:16
问题 There is a custom implementation of KSPA which needs to be re-written. The current implementation uses a modified Dijkstra's algorithm whose pseudocode is roughly explained below. It is commonly known as KSPA using edge-deletion strategy i think so. (i am a novice in graph-theory). Step:-1. Calculate the shortest path between any given pair of nodes using the Dijkstra algorithm. k = 0 here. Step:-2. Set k = 1 Step:-3. Extract all the edges from all the ‘k-1’ shortest path trees. Add the same

Suggestions for KSPA on undirected graph

折月煮酒 提交于 2019-12-19 03:14:07
问题 There is a custom implementation of KSPA which needs to be re-written. The current implementation uses a modified Dijkstra's algorithm whose pseudocode is roughly explained below. It is commonly known as KSPA using edge-deletion strategy i think so. (i am a novice in graph-theory). Step:-1. Calculate the shortest path between any given pair of nodes using the Dijkstra algorithm. k = 0 here. Step:-2. Set k = 1 Step:-3. Extract all the edges from all the ‘k-1’ shortest path trees. Add the same

Algorithm: shortest path between all points

馋奶兔 提交于 2019-12-18 19:07:08
问题 Suppose I have 10 points. I know the distance between each point. I need to find the shortest possible route passing through all points. I have tried a couple of algorithms (Dijkstra, Floyd Warshall,...) and they all give me the shortest path between start and end, but they don't make a route with all points on it. Permutations work fine, but they are too resource-expensive. What algorithms can you advise me to look into for this problem? Or is there a documented way to do this with the above