Questions tagged [dijkstras-algorithm]
Algorithm for solving the single-source shortest-path problem in non-negatively weighted directed graphs
59
questions
0
votes
1
answer
50
views
Dijkstra's shortest path algorithm
I am reading about algorithms to find the shortest path on a graph with one source, and I have a doubt about Dijkstra's algorithm about the negative weights on edges. In this case is Bellman-Ford ...
0
votes
1
answer
31
views
find the shortest path between two vertices with Dijkstra (Increase and deacrese wieght one by one)
We have a weighted and undirected graph.
I want to find the shortest path between two vertices with Dijkstra algorithm.
But in the path, the weight of the edges should be increased and decreased one ...
0
votes
2
answers
1k
views
CLRS Exercise 24.3-4 - Confirm Output of a Program Claiming to Implement Dijkstra's Algorithm
I'm trying to better understand Question 24.3-4 From CLRS below:
Professor Gaedel has written a program that he claims implements Dijkstra’s algorithm.
The program produces $v.d$ and $v.\pi$ for ...
0
votes
2
answers
89
views
Proof showing when Dijkstra’s algorithm fails for negative edge weights
How do I show the correctness proof of Dijkstra’s algorithm for negative edge weight
$\textbf{indicating the point in the proof where it breaks or does not hold}?$
I tried proving it like this, but i ...
0
votes
2
answers
170
views
subtract the weight of the largest edge
I have an oriented and weighted graph, and I need to find the cheapest route from source to destination.
Now I have a source node A and a destination node B the cheapest path is given to me by the sum ...
0
votes
0
answers
22
views
What's the average and worst-case time complexities of the following BFS for finding shortest paths?
Dijkstra's algorithm is the go-to method for finding the shortest path lengths between a source node and all the other nodes in a directed graph with nonnegative edge weights. I am wondering how ...
2
votes
1
answer
231
views
Dijkstra as a greedy algorithm
I'm preparing some material for students about greedy algorithms, and there is one point that confuses me: how Dijkstra's algorithm fits into the greedy framework.
I would like to say that we have ...
0
votes
1
answer
124
views
Does order of elements in a set matter in Dijkstra's Algorithm?
When we use a set for doing Dijkstra's Algorithm, we use a pair of {distance,node} which we insert in a set. Most of the articles say that the first element of pair should be the distance , else we ...
0
votes
0
answers
42
views
Dijkstra's runtime analysis in terms of $|V|$ and $|E|$
I'm unsure as to the amount of operations in Dijkstra's shortest path in terms of $|V|$ and $|E|$.
My guess is that there are (worst case - complete graph):
$$|V| + \sum^{|V|}_{i=1}{(|V|-i)} = \frac{|...
1
vote
1
answer
104
views
Shortest path in a directed weighted graph
Suppose we have a directed, weighted graph, $G = (V, E, w)$, with non-negative weights. We define the weight of the shortest path different from the original definition.
The weight of a path with at ...
2
votes
0
answers
73
views
Is there an efficient algorithm for calculating shortest path for multiple (source,target) pairs in a graph?
I wonder if there is an algorithm which takes multiple (source,target) pairs and a max_depth parameter and returns all or some of the paths found with those pairs?
Thinking of Dijkstra's algorithm, it ...
6
votes
1
answer
438
views
What role is the set, S playing in Dijkstra's algorithm given in the book CLRS?
I'm looking at Dijkstra's algorithm for single source shortest paths in a graph $G$ from a vertex $s$ from Introduction to Algorithms by Cormen et al. The $w$ parameter is the weight function such ...
1
vote
0
answers
55
views
compute shortest distance to a different sink
Given a directed graph G=(V, E) and a sink vertex t. Edge costs may be negative, zero,
or positive. consider d(v) contains the length of the shortest path from v to t
Given a new sink t2 in the graph, ...
0
votes
0
answers
154
views
bellman ford and dijkstra sparse vs dense graphs
I believe using big o notation that Bellman-Ford is to be expected to be faster on sparse graphs and dijkstra's should be expected to be faster on dense graphs, but in practice dijkstra's is always ...
0
votes
0
answers
59
views
binary heap vs regular list for dijkstra algorithm
I'm trying to understand at which densities (for example bounding $|E|^{1.5}<|V|<|E|^2$) is a normal list better than a binary heap (or a fibonacci heap).
From what I understand, the runtime of ...
1
vote
1
answer
273
views
How to find the lightest path that has at least one vertex of each color?
I've faced this question in my homework.
In a graph $G=(V,\ E)$ where every $v\in V$ has a color, a colored path is a path such that it has at least one vertex of each color.
We're given a directed ...
1
vote
0
answers
29
views
Node domination in constrained path search
It's possible to modify a graph search algorithm such as Dijkstra's or A* to allow for non-additive objectives or constraints. Is there a standard treatment for these algorithms to reduce unnecessary ...
-1
votes
1
answer
69
views
Dijkstra Algorithm
I have couple of questions about Dijkstra algorithm
Can the algorithm work if there are negative weights at the starting point?
Can we make the algorithm work with negative weights if we add a long ...
2
votes
1
answer
336
views
Dijkstra's Algorithm Invariant
I am trying to prove the first assertion in the following code, taken from notes of Damon Wischik:
...
0
votes
0
answers
418
views
Number of shortest paths between two nodes in undirected unweighted graph
I'm trying to devise a $O(|V| + |E|)$ algorithm to calculate number of shortest paths between $s$ and $f$ on a undirected, unweighted graph. Can someone please check my pseudo-code? Also, isn't
$O(|V| ...
1
vote
1
answer
554
views
Given a source and destination, find the path with minimum stress level in a Graph
I faced this problem in a hiring challenge which is now over.
I wrote a solution for the problem but at that time the judge gave me wrong answer. Afterwords I thought about the solution but couldn't ...
2
votes
1
answer
274
views
Dijkstra's Algorithm Same Node Added Multiple Times to Priority Queue
In the this discussion of Dijkstra's Algorithm appear the following comments:
...
1
vote
1
answer
122
views
Shortest path with forced intermediate nodes
I have a directed graph with roughly 2000 nodes, and roughly 4000 edges. I have created an application so the people that use it can easily see the path drawn on a map, if they e.g. want to find the ...
3
votes
3
answers
2k
views
Why is my implementation of Dijkstra's Algorithm using min heap faster than using an unsorted array for a complete graph?
Based on theory, the implementation using adjacency matrix has a time complexity of E+V^2 and the implementation using min heap has a time complexity of (E+V)logV where E is the number of edges and V ...
0
votes
0
answers
171
views
dijkstra with adjacency list and minimum heap as queue vs adjacency matrix and a normal array as "queue"
Which one should be faster? I have written a script comparing both run time, initially the implementation with adjacency list and minimum heap performs faster, but as the number of nodes/edges ...
2
votes
2
answers
1k
views
Can you use Dijkstra's algorithm to find the maximum cost path?
Suppose you have a DAG and the edges are positively weighted, and you want to find the maximum cost path from any node with no in degree to any node with no out degree.
Is it possible to negate all ...
6
votes
5
answers
2k
views
Example of a graph with negative weighed edges in which Dijkstra's algorithm does work
I was asked to give an example of a graph that has edges with negative weight, but Dijkstra's algorithm will still give us the correct output. It was part of a prove/disprove question. The claim was.. ...
0
votes
0
answers
86
views
A relaxation-free variant of Dijkstra's shortest path algorithm
I have come up with a relaxation-free variant of Dijkstra's shortest path algorithm, and I would like to see if it's correct. Here is the pseudocode for finding the shortest distance from a node $\...
2
votes
2
answers
1k
views
How does Dijkstra's problem 1 (tree of minimal total length) work and what does it do?
In Dijkstra's original paper, he talks about two problems related to graphs. The second one is the problem of finding the shortest path between two nodes, which is what is most commonly meant by ...
1
vote
2
answers
222
views
Dijkstra's algorithm in a weighted graph
The Dijkstra's algorithm is never used for a graph with a negative weight.
The following graph has negative weight but when the Dijkstra's single source shortest path algorithm run from vertex a, it ...
0
votes
1
answer
716
views
M + N log N running time for Dijkstra
I'm taking the Design and Algorithms Part -II course in Coursera by professor Tim Roughgarden. In one of the classes, he mentioned that the running time for Dijkstra is $O(m \log n )$ using the heap ...
0
votes
1
answer
94
views
Find an algorithm which returns the weight of a lightest path between all paths with a weight divided by three [duplicate]
Question: Find an algorithm which returns the weight of a lightest path between all paths with a weight divided by three in a graph with natural weights of the edges.
My instructor has given me a hint ...
1
vote
1
answer
24
views
Algorithm for shorthest path that contains exactly n edges of weight 2 in 1,2-weighted directed graph
I am trying to find an efficient algorithm for the following problem:
Input:
weighted directed graph G=(V, E) in which all edges are weigthed either 1 or 2
s,t ∈ V
n ∈ N
Output
shortest path from s ...
2
votes
0
answers
80
views
Which algorithms exhibits Greedy Choice Property but not Optimal Substructure Property
After a few courses using CLRS, I still have not been able to find a satisfying answer to the title question.
This answer suggests Hoffman trees. But here the greedy choice is the two subtrees with ...
5
votes
1
answer
1k
views
Dijkstra's algorithm vs A*
The A* algorithm terminates when the f (distance + heuristic) is less than the f values for all of the nodes that haven't been visited. Dijkstra's algorithm produces the shortest path to every node ...
-1
votes
1
answer
104
views
UCS and Dijkstra's algorithm do both of them give the minimal cost between two vertices?
i tried both algorithm to find the shortest path with minimal cost between two vertices,but most of the time Dijkstra gives a different path and the cost is smaller than the cost for the path UCS ...
0
votes
0
answers
73
views
How to modify the following Dijkstra/ Uniform-cost search to return the result for all end points?
I know there is a lot of code out there that does this, but in particular, I'm trying to modify the following code to not just return the goal node/ one end point, but all endpoints. How do I go about ...
0
votes
1
answer
930
views
find shortest paths from source to all vertices using Dijkstra’s Algorithm?
For Dijkstra’s,i can find shortest paths from source to all vertices in the given graph but how can i calling the algorithm |V| times taking each vertex as a source and store all tables ???
For ...
4
votes
1
answer
2k
views
Dijkstra without decrease key
I was reading through this paper, "Priority Queues and Dijkstra's Algorithm" by Mo Chen et al., which suggests using Dijkstra's without edge relaxation, but to rather to just insert new ...
1
vote
2
answers
493
views
Minimum distance in an undirected weighted graph to cover k nodes using teleportations
I have been practicing problems on graphs and shortest paths and
I encountered a problem that I'm struggling to understand.
Can you give me any tips and/or can you confirm that I got the general
...
2
votes
1
answer
140
views
shortest path in color-weighted graphs
I want to find an algorithm to find the shortest path in a vertex-colored vertex-weighted graph. Every vertex with the same color has the same weight and the total weight of a path should be the sum ...
0
votes
1
answer
2k
views
Why is DFS not suited for shortest path problem?
I am sorry for the repetition of the question. I understand that this question has already been answered before by the community, but most answers tend to focus on unweighted graphs. I want to know ...
1
vote
0
answers
105
views
Solving shortest path problem with Dijkstra’s algorithm for n negative-weight edges and no negative-weight cycle
Although many texts state Dijkstra's algorithm does not work for negative-weight edges, the modification of Dijkstra's algorithm can. Here is the algorithm to solve a single negative-weight edge ...
2
votes
0
answers
95
views
Fastest Algorithm for finding All Pairs Shortest Paths on Sparse Non-Negative Graph
As discussed here Johnson's Algorithm can be used to solve the APSP-Problem in $O(V^2\log V + VE)$ in stead of $O(V^3)$ for Floyd-Warshall. However, Johnsons Algorithm does quite a bit of work for the ...
0
votes
0
answers
196
views
Find every path that passes through certain edges
I'm faced with the following problem:
Given
Directed and unweighted graph, where each edge E has two attributes
Goal
Find every path through the 3 (or more) given edges in a specific order
...
0
votes
0
answers
25
views
Trivial clarification with the analysis of the Dijkstra Algorithm as dealt with in Keneth Rosen's "Discrete Mathematics and its Application"
I was going through the text, "Discrete Mathematics and its Application" by Kenneth Rosen where I came across the analysis of the Dijkstra Algorithm and felt that the values at some places ...
0
votes
1
answer
918
views
Create an algorithm for computing the shortest path in O(m + nlogn)
So I'm trying to write an algorithm for computing the shortest path with constraints on the vertices you can visit in $O(m + n \log n)$ time. In this problem, we are given an indirect weighted (non ...
2
votes
1
answer
202
views
Modified shortest path problem
For a given graph $G=(V,E)$ and a given weight function $W$ lets say we define the new weight for path p to be the regular weight minus the heaviest edge in that path, i.e: $w^*(p)=\varSigma(w(v_i,v_{...
1
vote
2
answers
978
views
Analysis of Dijkstra algorithm's (Lazy) running time
I'm trying to figure out the running time for a Dijkstra algorithm. All the sources I have read say that the running time is O(E * log (E)) for a lazy implementation.
But when we do the math we get ...
3
votes
2
answers
1k
views
Find the shortest path that goes through an even number of red edges
I'm looking for an algorithm for the problem:
"Given an undirected graph with positive weights on its edges and some of the edges are red and some are blue. Describe an algorithm that finds the ...