shortest-path

Shortest path in a maze with health loss

杀马特。学长 韩版系。学妹 提交于 2020-01-04 09:24:09
问题 Suppose you have a dungeon, represented by a 2D matrix. You have a start point S (x1,y1) and an end point E (x2, y2). Along the way, some cells have a number in them, which subtract from your health score. Other cells are obstacles that you can't go through. You start with 5 health points, and you need to find the shortest path from S to E where you don't die on the way. I know that Dijikstra is used to find shortest paths. But in this case the shortest path might be one in which you die

Shortest path in a maze with health loss

眉间皱痕 提交于 2020-01-04 09:23:07
问题 Suppose you have a dungeon, represented by a 2D matrix. You have a start point S (x1,y1) and an end point E (x2, y2). Along the way, some cells have a number in them, which subtract from your health score. Other cells are obstacles that you can't go through. You start with 5 health points, and you need to find the shortest path from S to E where you don't die on the way. I know that Dijikstra is used to find shortest paths. But in this case the shortest path might be one in which you die

About “Improved Dijkstra Algorithm” Paper

左心房为你撑大大i 提交于 2020-01-04 05:32:13
问题 I want to ask a few questions about the algorithm in this paper. https://pdfs.semanticscholar.org/9208/65aee7b072c054afa628ba413adda6f3e962.pdf You may wonder why I don't ask the authors directly, actually I have, but unfortunately, I've got no response and I couldn't find direct emails to the authors. You can see the core formula (8) of the algorithm. d(n) = weight value from starting point to current node r(n) = constraint function ɷ = weighted value denoting the impact factor θn = angle

K Shortest Path Python Not Working

天大地大妈咪最大 提交于 2020-01-04 05:14:09
问题 I'm having certain Issues with my K Shortest Path algorithm. The code is given as: def K_shortest_Paths(graph,S,T,K=4): '''Initialize Variables Accordingly''' B = {} P = set() count = {} for U in graph.keys(): count[U] = 0 B[S] = 0 '''Algorithm Starts''' while(len(B)>=1 and count[T]<K): PU = min(B,key=lambda x:B[x]) cost = B[PU] U = PU[len(PU)-1] del B[PU] count[U] += 1 if U==T: P.add(PU) if count[U]<=K: V = graph[U].keys() for v in V: if v not in PU: PV = PU+v B[PV] = cost+1 return P This is

Shortest path between two points through N checkpoints in a matrix

牧云@^-^@ 提交于 2020-01-03 06:20:13
问题 How to find shortest path between two points, namely S and D, in a matrix ? It should pass through multiple checkpoints named &. It cannot pass through G. * represents an open gate. Paths can pass through destination and checkpoints any number of times. Example: GGGGG GS**G GGDGG G**&G GGGGG Output for this matrix should be 6. 回答1: The problem is easy when you only have one waypoint that you have to visit. You find the path (using A*, for instance) to the waypoint and then the path from the

Using Existing Fibonacci Heap Java Implementation with Dijkstra's Shortest Path Java Implementation

青春壹個敷衍的年華 提交于 2020-01-01 07:32:06
问题 Using java programming language, I am trying to implement the most efficient shortest path algorithm on a graph with positive edge cost. To the best of my knowledge, that would be Dijkstra's algorithm with a Fibonacci Heap as the priority Queue. I borrowed the following Fibonacci Heap implementation by Keith Schwarz as stated in the link. http://keithschwarz.com/interesting/code/?dir=fibonacci-heap In my code, I also modified the dijkstra algorithm implementation presented in this question,

How to minimize total cost of shortest path tree

扶醉桌前 提交于 2020-01-01 03:11:06
问题 I have a directed acyclic graph with positive edge-weights. It has a single source and a set of targets (vertices furthest from the source). I find the shortest paths from the source to each target. Some of these paths overlap. What I want is a shortest path tree which minimizes the total sum of weights over all edges. For example, consider two of the targets. Given all edge weights equal, if they share a single shortest path for most of their length, then that is preferable to two mostly non

A* Algorithm for very large graphs, any thoughts on caching shortcuts?

北战南征 提交于 2019-12-31 08:14:06
问题 I'm writing a courier/logistics simulation on OpenStreetMap maps and have realised that the basic A* algorithm as pictured below is not going to be fast enough for large maps (like Greater London). The green nodes correspond to ones that were put in the open set/priority queue and due to the huge number (the whole map is something like 1-2 million), it takes 5 seconds or so to find the route pictured. Unfortunately 100ms per route is about my absolute limit. Currently, the nodes are stored in

shortest path from goal to root in directed graph with cycles python

谁说我不能喝 提交于 2019-12-31 05:58:45
问题 I want to find the shortest path from goal to root working backwards My input for root is {'4345092': ['6570646', '40586', '484']} My input for goal is {'886619': ['GOAL']} My input for path_holder is an input but it gets converted to dct and is used for this function. I am getting stuck regarding the while loop as it creates the path for me backwards. Right now I can't get q to print because that part of the code isn't being ran. dct is basically a directed graph representation that contains

Returning only the vertices in the actual shortest path

旧巷老猫 提交于 2019-12-30 06:59:13
问题 I know the title is a bit messy, but I don't know how to explain it better. What I'm trying to do: Using a graph found in a text file, find and print the shortest path (minimum amount of vertices) from vertex A to vertex B. Note: using breadth-first search, not Dijkstra's. What I've got: A working algorithm that applies BFS on the graph, but no good way of actually printing out the shortest path. I'm having a hard time distinguishing a vertex in the shortest path from one that is simply run