shortest-path

the best shortest path algoritm

hello all, what is the difference between the "Floyd-Warshall algorithm" and "Dijkstra's Algorithm", and which is the best for finding the shortest path in a graph? I need to calculate the shortest path between all the pairs in a net and save the results to an array as follows: **A B C D E** A 0 10 15 5 ...

Modification of shortest path algorithm (route from a node to itself)

I am applying the all-pairs shortest path algorithm (Floyd-Warshall) to this directed graph: The graph is represented by its adjacency matrix. The simple code looks like this: public class ShortestPath { public static void main(String[] args) { int x = Integer.MAX_VALUE; int [][] adj= { {0, 6, x, 6, 7}, ...

How to calculate the shortest path between two points in a grid

Hello! I know that many algorithms are available for calculating the shortest path between two points in a graph or a grid, like breadth-first, all-pairs (Floyd's), Dijkstra's. However, as I noticed, all of these algorithms compute all the paths in that graph or grid, not only those between the two points we are interested in. MY QUES...

Knight's Shortest Path Chess Question

I've been practicing for an upcoming programming competition and I have stumbled across a question that I am just completely bewildered at. However, I feel as though it's a concept I should learn now rather than cross my fingers that it never comes up. Basically, it deals with a knight piece on a chess board. You are given two inputs: s...

finding shortest path from undirected graph

I have two problems; I have to find shortest path from an undirected, weighted graph sending goods to single destination sending goods to multiple destinations Assume all edge weights are positve numbers. Send me suitable algorithms for both problems. ...

Non-cycle path to all nodes

Is there an algorithm or set of algorithms that would let you find the shortest walking distance from an arbitrary start node so that every node gets visited in a weight, undirected graph? It's not quite Traveling Salesman, because I don't care if a node is visited more than once. (It doesn't even matter if you make it back to the start ...

Finding all shortest paths from every pair of nodes on a graph

I have about 70k nodes, and 250k edges, and the graph isn't necessarily connected. Obviously using an efficient algorithm is crucial. What do you recommend? As a side note, I would appreciate advice on how to divide the task up between several machines--is that even possible with this kind of problem? Thanks ...

Finding the shortest path between two points on a grid, using Haskell.

This is a problem that I can easily enough solve in a non-functional manner. But solving it in Haskell is giving me big problems. Me being inexperienced when it comes to functional programming is surely a reason. The problem: I have a 2D field divided into rectangles of equal size. A simple grid. Some rectangles are empty space (and c...

Algorithm: shortest path between all points

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 ...

How to optimize Dijkstra algorithm for a single shortest path between 2 nodes?

Hi, I was trying to understand this implementation in C of the Dijkstra algorithm and at the same time modify it so that only the shortest path between 2 specific nodes (source and destination) is found. However, I don't know exactly what do to. The way I see it, there's nothing much to do, I can't seem to change d[] or prev[] cause th...

Dijkstra shortest path algorithm with edge cost.

Hello, I have a directed, positive weighted graph. Each edge have a cost of use. I have only A money, i want to calculate shortest paths with dijkstra algorithm, but sum of edges costs on route must be less or equal to A. I want to do this with most smallest Dijstra modification (if I can do it with small modification of Dijkstra). I ...

Shortest-path algorithms which use a space-time tradeoff?

Problem: finding shortest paths in an unweighted, undirected graph. Breadth-first search can find the shortest path between two nodes, but this can take up to O(|V| + |E|) time. A precomputed lookup table would allow requests to be answered in O(1) time, but at the cost of O(|V|^2) space. What I'm wondering: Is there an algorithm which...

Getting shortest path between 2 nodes in quickgraph

Hello, i want to ask if there is any way to generate the shortest path from node A to node B without generating the shortest paths to all the other nodes (stop when node B is in the examined set) with A-star in QuickGraph. I want to plug QuickGraph into a game and thus generating all the paths is not allowed from the time limitations th...

shortest path search in a map represented as 2d shapes

Hi, I have a small library of a few shortest path search algorithms. They were developed for simple undirected graphs (the normal representation - vertices and edges). Now I'd like to somehow apply them on a bit different scenario - where the maps are represented as 2-dimensional shapes, connected by shared edges (edges of the polygons,...

Is there any library in R to work with graphs (find shortest path and so on)?

Hi! I know that R is statistical pkg, but probably there is library to work with graphs and find shortest path btw 2 nodes. PS actually, I've found igraph and e1071, which one is better? Thank you ...

Boost BGL thread safety

Hi! I'd like multiple threads to use the dijkstra_shortest_paths and astar_search functions of the BGL, and then read the property maps of the result vertices and edges. I'm wondering wether I should use mutexes to ensure thread-safety. So here are my questions: 1., Are the dijkstra_shortest_paths and astar_search functions of the Bo...

How to minimize total cost of shortest path tree

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, con...

Calculating Divergent Paths on Subtending Rings

I need to calculate two paths from A to B in the following graph, with the constraint that the paths can't share any edges: hmm, okay, can't post images, here's a link. All edges have positive weights; for this example I think we can assume that they're equal. My naive approach is to use Djikstra's algorithm to calculate the first pat...

Efficiently finding the shortest path in large graphs

I'm looking to find a way to in real-time find the shortest path between nodes in a huge graph. It has hundreds of thousands of vertices and millions of edges. I know this question has been asked before and I guess the answer is to use a breadth-first search, but I'm more interested in to know what software you can use to implement it. F...

Performance of shortest path algorithm in JUNG API

I use the JUNG API to calculate shortest paths between several nodes in medium large graphs (20 to 100 nodes). Right now I'm iterating over my nodes and use the simple 'ShortetsPath' function to calculate the shortest path for two nodes. All the shortest paths are put in an ArrayList. UnweightedShortestPath<Vertex, SEdge> dist = new Unw...