Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
0 answers
79 views

Imagine you get sequence of integers: [a1 a2 a3 ... an] where: 1 <= a <= 10^6 1 <= n <= 10^6 You are given a function f(x) that can change a number to the closest lower prime number, or ...
1 vote
2 answers
596 views

I have very well understood Optimal substructure property of shortest path. Which says that- A shortest path from x to y via z contains a shortest path from x to z. Now I want to understand how ...
4 votes
0 answers
1k views

I am trying to understand Thorup's latest priority Queue which has delete_min operation O(log log N) as presented in his paper. He refers to Fredman and Williard's Atomic Heap as a part of his ...
-3 votes
1 answer
122 views

While working in LeetCode 675, I came across a weird behavior with PriorityQueue Comparator that I can't explain. For brevity, I'll state the gist of the problem statement; interested parties can read ...
5 votes
1 answer
80 views

It is alleged that the standard BFS can be extended to output all possible shortest paths between two given vertices in a directed unweighted graph (without loops? it does not seem to matter whether ...
14 votes
3 answers
28k views

I have a graph and I want to find all shortest paths between two nodes. I've found a shortest path between two nodes by BFS. However, it just gives me one of the shortest paths if there exists one ...
133 votes
10 answers
121k views

I am trying to understand why Dijkstra's algorithm will not work with negative weights. Reading an example on Shortest Paths, I am trying to figure out the following scenario: 2 A-------B \ /...
1 vote
2 answers
808 views

I have read in other posts that Dijkstra's algorithm always expands the shortest path first. Why must it be implemented in such a way? Say we created a relaxed version of Dijkstra's that expands any ...
1 vote
1 answer
176 views

I stumbled upon a problem like this: Let's say you have some number of grids. Each grid have the same dimension of rows and columns. Each cell in grid can be represented as either L or _ . Also take ...
1 vote
1 answer
54 views

I came across a strange behavior, which I do not understand and might also be a bug. By coincidence, I found out that the distance in the rail network between Latvia and Poland is significantly higher ...
1 vote
2 answers
179 views

From "Montreal" as the origin point, I'm trying to find the shortest path to go to another city. But I'm having difficulty when a city is looped. demo at db<>fiddle create table ...
11 votes
2 answers
16k views

I'm trying to understand exactly how these algorithms work, but I have been unable to find a simple explanation. I would greatly appreciate it if someone could provide me with a description of these ...
3 votes
3 answers
176 views

Given a directed graph with positive edge weights, a source vertex, a destination vertex, and a integer M (M < 10), find the shortest path from the source to the destination. The twist is that M ...
0 votes
1 answer
53 views

R user learning Python here. I have an undirected unweighted edgelist and I want a distance matrix, showing the shortest path between all my nodes. There are about 30000 nodes and 40000 edges, and my ...
0 votes
1 answer
137 views

Using A star algorithm, it is easy to calculate the shortest path from the source point to target point. What if we add the constraint of necessary points? How to solve it ? necessary points is a set ...
0 votes
1 answer
195 views

The question asks about the maximum number of elements that can be present in the priority queue at any given time during the execution of Dijkstra's algorithm on the given graph. I coudn't understand ...
0 votes
2 answers
126 views

I am using Neo4j 5.9.0 community Problem description : My graph only has one type of relationship [:Relationship], and one type of node (:Node). I want to find the shortest path between two nodes, but ...
1 vote
1 answer
165 views

Context: I want to write an algorithm for finding the shortest(least cost) path from a fixed source to a fixed destination node in a weighted directed graph with non negative weights (can have cycles)....
1 vote
1 answer
842 views

What I'm thinking is, for each edge in the set of edges I can pick from, build a copy of the graph with that edge inserted into it, then run Dijkstra’s. The best edge will be from the graph with the ...
0 votes
1 answer
307 views

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 ...
4 votes
4 answers
5k views

I am trying to get all shortest paths between all pairs of nodes in an undirected unweighted graph. I am currently using nx.all_pairs_shortest_path(), but I don't understand why it only returns one ...
2 votes
1 answer
482 views

I'm working on a personal project that requires solving the well-known shortest-path problem. I have 256x256 tiles maps like the following: Example map I'm only interested in white (walkable) areas. ...
0 votes
1 answer
96 views

As I opted for option 1 and 3 (-6, infinity),(-7, Infinity) and applied the Bellman-Ford algorithm for shortest path calculation, the calculation did not show any negative cycles after n’th steps for ...
0 votes
3 answers
171 views

I'm currently working for a project with TOP and I'm asked to find the shortest path between 2 squares with a Knight on a 8x8 chessboard. Imagine I want to go from 0,0 to 7,7, my algo need to return ...
0 votes
0 answers
44 views

I was given a problem that in a connected, weighted graph G = (N, A), find a connected subgraph G_s = (N_s, A_s), where |N_s| <= l and A_s = {(i, j): i \in N_s, j \in N_s, (i, j) \in A}, such that ...

1
2 3 4 5
40