209 questions
-1
votes
1
answer
64
views
What is correct path tracking in Floyd-Warshall algorithm?
There are several descriptions of the Floyd-Warshall algorithm, including the one in Wikipedia where path tracking logic described like in the pseudo-code below (copy from Wikipedia https://en....
0
votes
0
answers
139
views
Does output count for space complexity in an algorithm?
It's controversial when I search answers on the internet. Most people tend to omit the space of output. However, when I search the space complexity of Floyd-Warshall algorithm, all shown are O(n^2) ...
0
votes
1
answer
85
views
Condition for loop in Floyd–Warshall algorithm
I'm learning a basic shortest-route algorithm specifically Floyd–Warshall algorithm.
I understood how efficient it is when finding 'All to All' distance.
But while reading a code from the book I'm ...
1
vote
1
answer
371
views
Is it true that if we apply any single source shortest path algorithm for each vertex, it will turn into an all pair shortest path algorithm?
For example, if I ran Dijkstra's algorithm for each vertex, would that produce the all pair shortest path for the entire graph like when running Floyd-Warshall?
I am leaning towards this being true ...
2
votes
5
answers
645
views
How to handle arrays of extremely large strings in C#
I'm implementing the Floyd-Warshal algorithm, as can be found here.
I'm not just interested in the shortest distance between nodes, but also in the path, corresponding with that distance.
In order to ...
-1
votes
1
answer
160
views
Why would one consider using Bellman Ford?
So, say you wanted to find the shortest path between two vertices.
I would argue this:
A.) If the graph has no negative edge weights and is represented by an adjacency list, you could run Dijkstra's ...
0
votes
1
answer
230
views
A shortest path with fuel constraints using Floyd-Warshall
I tried to write pseudo-code based on this solution.
But I couldn't understand this part "Once we have run Bellman-Ford, we can look back at the results from Floyd-Warshall to determine whice ...
0
votes
1
answer
343
views
add cycles with negative weights check in Floyd-Warshall
This is the pseudo-code for the Floyd-Warshall algorithm for shortest paths detection:
I was wondering if it would be possible to add a check that will test if there are no cycles with negative ...
0
votes
0
answers
120
views
Floyd Warshall Algorithm returning None
def floydWarshall(self) :
n = len(self._W)
D = copy.deepcopy(self._W)
P = copy.deepcopy(self._W)
for i in range(n) :
for j in range(n) :
if i == j or self._W[...
1
vote
1
answer
67
views
modify current algorithm - APSP
I have the below APSP algorithm:
This computes the shortest path. The length of the path is the sum of weights of edges of path.
How can i modify the above algorithm in order to compute the shortest ...
0
votes
0
answers
351
views
How to implement Floyd Warshall on a grid?
just started learning some search algorithms. So I've kinda hit a roadblock (in concept too) about the Floyd Warshall's algorithm for the shortest path. The problem is that I've been given a grid with ...
6
votes
2
answers
2k
views
How do I select the node that minimizes the maximum shortest distance to the other nodes in a graph?
I have an undirected, connected, positively-weighted graph G = <V,E>. I need to find one node v_min in V such that the maximum distance between v_min and the other nodes are minimized. I've ...
0
votes
0
answers
1k
views
Google Foobar Level 4 RunningWithTheBunnies
I am stuck on one test case for the foobar problem.
Question and my code are given below
You and your rescued bunny prisoners need to get out of this
collapsing death trap of a space station - and ...
1
vote
2
answers
567
views
Sub-graph Selection Algorithm Problem (Dynamic Programming or NP)
We have an algorithm problem in hand, can you please write your ideas about this, thank you!
There are N many nodes with K different colors. Some of the nodes have direct connection between each other ...
2
votes
1
answer
175
views
In graph data structure how can we use intermediate node to calculate distance of any other two nodes?
In floyd warshell algorithm we keep any node y as intermediate node and update distance from one node to another(for all nodes) via intermediate node y.
dp[x][y] = min( dp[x][y] , dp[x][z] + dp[z][y])
...
2
votes
3
answers
594
views
Python networkx: Does the floyd_warshall_numpy work properly?
Can someone confirm my finding the implementation of floyd_warshall_numpy method of networkx 2.5 is incorrect?
The code to reproduce is:
G = nx.balanced_tree(2, 3)
print(G.nodes())
print(nx....
-1
votes
1
answer
189
views
Is it possible to calculate the shortest path using Floyd Warshall's algorithm with a weight limit (C++)?
The point of the weight limit is that the algorithm should not use paths that exceed that limit even if it is the shortest path.
So if the weight limit was 50, in the graph below the algorithm should ...
3
votes
2
answers
612
views
Does rearranging the outerloop in Floyd-Warshall algorithm as most inner loop change the algorithm
The following code is for Floyd-Warshall algorithm
for (int k = 0; k < n; ++k) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
d[i][j] = min(d[i][j], d[i]...
0
votes
1
answer
775
views
what is the best way to get all pair shortest path in very large scale weighted and directed graph?
I'm trying to find all pair shortest path in very large scale graph. I tried floyd-warshall but it is not fast enough because of very large scale of the graph. Number of vertices is more than 100k. ...
0
votes
1
answer
54
views
What is the right way in R to iterate over a multidimensional array and compare it's elements?
I am trying to implement Floyd Warshall's algorithm in R. When I run the programm I get the following error:
Error in if ((graph[i][k] + graph[k][j]) < graph[i][j]) { :
argument is of length zero
I ...
0
votes
1
answer
107
views
Print dictionary elements as a list of paths
I am trying to print all possible paths using Floyd-Warshall algorithm and networkx (Python). The thing is, I don't know how to do it properly (readable, as a list).
I have these paths from my graph:
...
1
vote
1
answer
1k
views
How to find a collision of first 56 bits for MD5(MD5(x)) for input data with the same prefix?
I have a code to find the collision of the first 56 bits of the hash function: md5(md5(x)) (using the Floyd algorithm to find cycles).
The script returns two strings (hare, tortoise) for which a ...
2
votes
0
answers
51
views
Floyd algorithm shortest path
i have written the code below,it works for shortest distance but not for shortest path,
import math
def floyd(dist_mat):
n=len(dist_mat)
p=[[0]*n]*n
...
0
votes
1
answer
65
views
Technique of returning two int[][] array and not getting a java.lang.ArrayIndexOutOfBoundsException: -1 error
I have a personal coding question. I'm trying to code in java a Floyd-Warshall algorithm, with a predecessor matrix. My goal is to return both the matrix array and predMatrix which I don't know how to ...
0
votes
0
answers
181
views
Q: Error: Exception in thread "main" java.util.InputMismatchException
I am writing a program to solve the all-pairs shortest paths problem using the Floyd-Warshall algorithm. I am given a test file in txt format in which the first int is the number of vertices, the ...