1,927 questions
2
votes
1
answer
85
views
how to prove distance[v] ≥ length(P) for shortest path P through processed vertices?
In Dijkstra’s algorithm, how do you prove that at any moment:
distance[v] ≥ length(P)
for shortest s → v path P where all vertices (except possibly v) are already processed (i.e., not in the priority ...
0
votes
1
answer
101
views
How to speed up code for Leetcode 2290 "minimum obstacle removal to reach corner"
i am solving some leet code solutions.
But with this hard question, i am not sure how to speed up my algorithm more.
https://leetcode.com/problems/minimum-obstacle-removal-to-reach-corner/submissions/...
3
votes
1
answer
70
views
Counterexample When Replacing Bellman-Ford with Dijkstra in Johnson’s Algorithm
Counterexample When Replacing Bellman-Ford with Dijkstra in Johnson’s Algorithm
Question:
I have an implementation of Johnson’s Algorithm, which modifies edge weights in a graph. Below is the ...
0
votes
0
answers
82
views
Multiple errors in Dafny implementation of Dijkstra's algorithm
I am trying to program Dijkstra's algorithm in Dafny using the following classes which I programmed.
The Pair<T> class:
class Pair <U,V>{
var first:U
var second:V
constructor (x:U, ...
1
vote
1
answer
57
views
Understanding Runtime for Naive Implementation of Dijkstra Algorithm
I am pulling my hair understanding the runtime for the naive (no heap) implementation of Dijsktra algorithm, and potentially if there is a better code for this naive implementation.
The runtime ...
0
votes
1
answer
117
views
How to find shortest path in neo4j with property filters but without GDS?
I want to find a shortest path in neo4j between a start and end node. The graph is weighted with properties "costs" and "transit_time".
I wanna find the shortest path in terms of ...
0
votes
0
answers
43
views
Is it possible to start a Dijkstra search from a source node s, bounded at r, with known shortest distances from s smaller than r?
I am implementing a complex shortest path algorithm for large graphs in C++.
This algorithm basically constructs a hierarchy of shortcut graphs by utilizing nice properties.
The first step in the ...
2
votes
1
answer
103
views
Struggling with Shortest Path Calculation in Graph with Special Edge Weights
I've been working on a problem where I need to find the shortest path in a graph considering two types of edge weights: normal and special. Check Problem Here.
I have constructed an adjacency list and ...
2
votes
1
answer
462
views
Dijkstra's algorithm vs Viterbi algorithm
Viterbi and Dijkstra's algorithm seem to be used in different contexts:
Viterbi algorithm is usually employed to solve maximum likelihood sequence problems (I've used for this purpose in ...
0
votes
1
answer
307
views
Bellman-Ford with Adjacency List (Shortest-path with negative weights)
I'm implementing my own version of the Bellman-Ford algorithm to find shortest paths with negative weights. However I'm not sure if this is correct, since in my opinion the complexity in my solution ...
0
votes
2
answers
105
views
Find shortest path between two nodes, all paths are equal to one
Is Dijkstra's algorithm the most suitable for finding the shortest distance between two nodes, where all of the paths in the graph are equal to 1.
If not what is a more time efficient way of ...
0
votes
0
answers
58
views
Refrence to "..." is ambiguous [duplicate]
I am trying to implement Dijkstra's algorithm to solve a problem for school, but I keep getting the error "Reference to distance is ambiguous".
Here is my code:
#include <bits/stdc++.h>...
0
votes
0
answers
53
views
Implementing restrictions via multiple links into dijkstra routing algorithm
I have successfully implemented a Dijkstra algorithm for finding optimal routes in road networks. I have constructed the data so that there are no "nodes", instead I use road segments, and ...
2
votes
1
answer
615
views
Shortest path finding in grid with turn cost
Stack Overflow community!
I'm working on a pathfinding problem within a 3x3 grid, where each cell has a variable cost based on its coordinates, and there are additional costs for making 90-degree ...
1
vote
0
answers
236
views
pgr_dijkstra returns "invalid memory alloc request size 1080000000" for large table
Consider postgressql 14.11 (Ubuntu 14.11-0ubuntu0.22.04.1) and the following table
CREATE TABLE test_path (id INTEGER, source INTEGER, target INTEGER, cost NUMERIC);
INSERT INTO test_path (id, source, ...
1
vote
1
answer
152
views
undirected graph - Shortest path with Vertex and edges Weight
the exercise:
in undirected graph vertices have can have weights in addition to the weights of edges
This problem is to write algorithem that finding the cheapest path between vertices a and b in a ...
1
vote
0
answers
43
views
Obtaining the resulting graph from ShortestPathsDijkstra
I'm working on a personal project which basically boils down to a typical Traveling Salesman problem (frequently have to go to ~20 different locations ensuring I go to all of them in the shortest ...
0
votes
0
answers
94
views
How can I add one stop point to the distance between two cities in the Dijkstra algorithm?
In a project at school, the teacher gave us 10 cities and their pairwise distances, and asked us to find the minimum distance from Izmir to Van but with the following restriction:
You start from ...
0
votes
0
answers
76
views
i have greedy and dijkstra algorithms with the same distance. My question is which distance to choose, B to C or B to D
The problem I marked in the picture is choosing the shortest path for the greedy and Dijkstra algorithms, now I'm confused because there are 2 identical paths, namely B to C and B to D. Which path ...
2
votes
1
answer
286
views
Potential optimizations for frequently repeating Dijkstra's algorithm?
I'm solving a programming problem involving finding the shortest path between a vertex and the rest of the graph. Currently, I'm using Dijkstra's algorithm to achieve that.
However, the problem ...
0
votes
1
answer
593
views
Creating dijkstras algorithm and having issues in C language
In my program, I'm tasked to take the first input, node names, then depending on the count of the node names we enter x amount of lines of graphs for the matrix used to display the possible paths for ...
0
votes
0
answers
84
views
How to change the criteria of the Dijkstra algotithm when trying to find the shortest path? [duplicate]
I am working with a undirected graph which relates some places to have fun in an amusement park. Each vertex is a place and each node gives us the distance and the average time between two places.
How ...
1
vote
0
answers
64
views
Why does my Dijkstra's return the incorrect result? [duplicate]
I'm doing my first Dijkstra's algorithm problem from LeetCode and I'm struggling to understand why it's failing. I'm stuck, and I don't want to look at other implementations without understanding what'...
0
votes
2
answers
51
views
Priority Queue is not adding the correct data to the queue
I am trying to solve a problem using a priority queue, where I have a two dimensional array times where indexes in the second dimension representing
starting edge,
ending edge, and
the distance ...
0
votes
1
answer
73
views
find a path that contains only one special edge
I meet a question, which ask me to find a path from start node to the destination node in a undirected graph, which the minimal weight along the path is larger or equal to any other path. And there ...