What is more important to know for FAANG interviews: Dijkstras or bellman Ford algorithm?
๐Ÿ‘︎ 32
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/googleybruh
๐Ÿ“…︎ Aug 18 2021
๐Ÿšจ︎ report
Why do we iterate V-1 times in Bellman Ford Algorithm?

Relaxing the edges from node 0 to V and using DP should give us the shortest path to each edge. I know BF covers negative cycles, but why exactly do we have to iterate V-1 times to figure out the shortest path and if a negative cycle exists or not? Can someone please explain BF a bit more clearly?

๐Ÿ‘︎ 11
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Bhavishya26
๐Ÿ“…︎ Jun 09 2021
๐Ÿšจ︎ report
What is the pseudocode for finding the all pairs shortest path using specifically the Bellman-Ford's Algorithm?

My professor has asked me to figure out a pseudocode that uses the technique used in Bellman-ford algorithm and find the all pairs shortest paths. The graph contains negative edges and is a directed and weighted graph.

My professor follows the CLRS book and I did read it and found that if you run a single source shortest path algo like the bellman-ford algo V times like for all the vertices, this will find the all pairs shortest path.

Should the pseudocode be like this?

Mod-Bellman-Ford(G,w,s)

Initialise-Single-Source(G,s)

For each vertex v that belongs to V

For i=1 to |G.V|-1

For each edge (u,v) that belongs to G.E

Relax(u,v,w)

For each edge (u,v) that belongs to G.E

If v.d > u.d + w(u,v)

Return False

Return True

Can anybody help me with this? :( i don't know if its correct or not. Just want to verify whether its correct or completely wrong.

๐Ÿ‘︎ 7
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/BabaYaga141
๐Ÿ“…︎ May 21 2021
๐Ÿšจ︎ report
[data structures] Time complexity of the Bellman Ford algorithm on weighted DAG's?

So, I've been taught in my class that the Bellman Ford algorithm has a time complexity of O(|v*e|) where v is the number of vertices of a graph and e is the number of edges. Although that time complexity is particularly for a directed weighted graph with a potential cycle, and a negative one at that. So I'm wondering what would the time complexity of the Bellman Ford algorithm be for a weighted directed graph with no cycles? I looked it up, and apparently it is O(|v|+|e|), or linear time. Is this true?

Update: no it's not.

๐Ÿ‘︎ 5
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Trick_Tangerine172
๐Ÿ“…︎ Nov 15 2020
๐Ÿšจ︎ report
Distance Vector Algorithm (Bellman Ford) - Computerphile youtube.com/watch?v=NdKcjโ€ฆ
๐Ÿ‘︎ 3
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/subscribe-by-reddit
๐Ÿ“…︎ Nov 20 2020
๐Ÿšจ︎ report
Can someone explain Johnson's algorithm and Bellman-ford algorithm?

After reading up on them I am still a bit comfused

๐Ÿ‘︎ 4
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/SleepyNutZZZ
๐Ÿ“…︎ Nov 08 2019
๐Ÿšจ︎ report
Question related to Bellman Ford Algorithm

In example from CLSR pg 652, we are getting -2 at the z node, so it must return FALSE as there is negative cycle is present. But it says it will return TRUE.

https://imgur.com/a/SFJn8

๐Ÿ‘︎ 6
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/abhi_000
๐Ÿ“…︎ Mar 06 2018
๐Ÿšจ︎ report
Has anyone heard of Bellman's algorithm? (not Bellman-Ford)

As above has anyone heard of so called Bellman's algorithm or recognise the description? I was taking a look through an old course book and came across it. It's a shortest path algorithm whose key benefit was in detecting negative length cycles. Only thing is I can't find any reference to it online. Does anyone have much info on what another name for this algorithm is?

https://preview.redd.it/zfworimwkxr11.jpg?width=2610&format=pjpg&auto=webp&s=4c6a227caf648aec1388ea7e6917bcf65185cbd5

๐Ÿ‘︎ 11
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/citizen_kiwi
๐Ÿ“…︎ Oct 13 2018
๐Ÿšจ︎ report
Bellmanโ€“Ford Algorithm programmingalgorithms.comโ€ฆ
๐Ÿ‘︎ 23
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/abcrink
๐Ÿ“…︎ Jun 24 2016
๐Ÿšจ︎ report
Shortest Path Algorithms (Dijkstra's Algorithm, Breadth-First Search, Bellman-Ford, Floyd-Warshall and Johnson's Algorithm) catonmat.net/blog/mit-intโ€ฆ
๐Ÿ‘︎ 163
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/pkrumins
๐Ÿ“…︎ Jan 27 2009
๐Ÿšจ︎ report
Btc-e Bitcoin/Litecoin/Fiat Arbitrager bot. Uses Bellman-Ford algorithm to find profitable cycles of trades. github.com/a-r-d/Bellman-โ€ฆ
๐Ÿ‘︎ 22
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/ardme
๐Ÿ“…︎ Nov 21 2015
๐Ÿšจ︎ report
Explanation required on Bellman-Ford Algorithm.

https://imgur.com/a/USLJs

I didn't know where else to post this question so i posted here.

If you look at the first row in the table it says that d(w) is 0, but in the second row it says that d(w) is 2. I'm having a hard time understanding as to why is d(w) = 0 in the first line and 2 in the second? And also when in the real world would someone use a bellman-ford algorithm?

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/the_illumintai
๐Ÿ“…︎ Mar 23 2018
๐Ÿšจ︎ report
TIL The Bellman-Ford algorithm was first proposed by Alfonso Shimbel in 1955, but is instead named after Richard Bellman and Lester Ford, Jr., who published it in 1958 and 1956, respectively. en.wikipedia.org/wiki/Belโ€ฆ
๐Ÿ‘︎ 17
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/bragi92
๐Ÿ“…︎ Apr 16 2017
๐Ÿšจ︎ report
Can anyone elif5 Bellmanโ€“Ford algorithm in the context of trading?
๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/john_legend_
๐Ÿ“…︎ Jan 03 2018
๐Ÿšจ︎ report
Is this the correct way to demonstrate proof by contradiction for the optimal substructure property of the Bellman Ford Algorithm?

I am watching a video on coursera and the following case was stated to be obvious by contradiction.

Let G = (V,E) be a directed graph with edge lengths C(e) and source vertex s. For every v in set V and i less than |v| let P = shortest s-v path with at most i edges.

Case 1: If P has <= (i - 1) edges, it is a shortest s-v path with <= (i - 1) edges.

My attempt at proof by contradiction is:

Suppose P is a shortest S-V path and has greater than (i-1) edges. Then P is a shortest path with >(i-1) and <=(i-1) edges. It cannot be the case that P has both >(i-1) and <=(i-1) edges, and so P must have <=(i-1) edges. This seems kind of silly to me.

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/DIYjackass
๐Ÿ“…︎ Jan 22 2018
๐Ÿšจ︎ report
ELI5: Dijkstra's algorithm or the Bellman Ford algorithm

I understand how to implement A*, but I don't understand the theory behind it, and I don't understand these two algorithms at all

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/inconspicuous_male
๐Ÿ“…︎ May 22 2013
๐Ÿšจ︎ report
[Java] Bellman-Ford Distance Vector Algorithm

I'm trying to code a program for a class that simulates a router and so far I have the basics set up ("router" can send and receive packets through an emulated server to other "routers" connected to the server). Each packet contains only the distance vector for that router. When a router receives a packet it is supposed to update it's own distance vector accordingly using the bellman-ford algorithm. The problem i'm having is that I am finding myself unable to implement the actual algorithm without cheating and using an adjacency matrix.

For example, say I have 3 routers connected as follows:

A ---1--- B ---2--- C

That is, A and B are connected with a link cost of 1, and B and C are connected with a link cost of 2. So when the routers are all started, they will send a packet to each of their directly connected neighbors containing their distance vector info. So A would send router B (0, 1, INF), B would send A and C (1, 0, 2) and C would send B (INF, 2, 0) where INF means the 2 routers are not directly connected.

So lets look at router A receiving a packet from router B. To calculate the minimum costs to each other router using the Bellman-Ford algorithm is as follows.

Mincost(a,b) = min((cost(a,b) + distance(b,b)),(cost(a,c) + distance(c,b))

Mincost(a,c) = min((cost(a,b) + distance(b,c)),(cost(a,c) + distance(c,c))

So the problem I am running into is that I cannot for the life of me figure out how to implement an algorithm that will calculate the minimum path for a router to every other router. It's easy enough to make one if you know exactly how many routers there are going to be but how would you do it when the number of routers can be arbitrarily big?

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Nantook
๐Ÿ“…︎ Nov 22 2012
๐Ÿšจ︎ report
ELI5: Bellman-Ford Algorithm and Dijkstra's Algorithm

I understand what they are for, and I even implemented Dijkstra's in some code a while back, but I am having a hard time wrapping my head around the Bellman-Ford Algorithm. Is there a heuristic to understand it?

๐Ÿ‘︎ 3
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/LeonardTimber
๐Ÿ“…︎ Feb 11 2013
๐Ÿšจ︎ report
[R] Logistic Q-Learning: They introduce the logistic Bellman error, a convex loss function derived from first principles of MDP theory that leads to practical RL algorithms that can be implemented without any approximation of the theory. arxiv.org/abs/2010.11151
๐Ÿ‘︎ 138
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/hardmaru
๐Ÿ“…︎ Oct 22 2020
๐Ÿšจ︎ report
"Logistic Q-Learning", Bas-Serrano et al 2020 (They introduce the logistic Bellman error, a convex loss function derived from first principles of MDP theory that leads to practical RL algorithms that can be implemented without any approximation of the theory.) arxiv.org/abs/2010.11151
๐Ÿ‘︎ 8
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/gwern
๐Ÿ“…︎ Oct 22 2020
๐Ÿšจ︎ report
Below you will find a link to a Zoom recording where our team discusses Reinforcement Learning. Topics covered: Markov Decision Process, Double Q-Learning, the math behind Q-Learning, and the Bellman Equation. We also walk through the algorithms and provide coded examples.

Topic: Reinforcement Learning Math Discussion

Meeting Recording:

https://us02web.zoom.us/rec/share/xcdlLPLzrmxLfNbNuFHud4UtFaTVeaa823IYr6dYzUw-uzo3Q0gjSQwweD9oLgzf

๐Ÿ‘︎ 41
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/davidstroud1123
๐Ÿ“…︎ May 19 2020
๐Ÿšจ︎ report
Bellman-Ford for Gold #2

I did Bellman-Ford for Gold #2 because it seemed pretty obvious. However, I ended up doing N-1 relaxations which were unnecessary after thinking about it after the contest was over. Then, I realized that you only need K-1 relaxations. Is this approach correct?

K < 50

N < 50000

With these numbers, doing K-1 relaxations seems to be 1000x faster than N-1 relaxations which seems like a great optimization. I only got test cases 1, 2, 3, 5 with the N-1 relaxations method. Will I get all the test cases with K-1 relaxations? The thing about relaxations in Bellman-Ford is, is that if you go over the optimal number of relaxations, you'll still get the correct answer, but slower so I could technically set the for loop to go to a max of 50 relaxations which is still pretty fast.

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/lopkiloinm
๐Ÿ“…︎ Jan 26 2021
๐Ÿšจ︎ report
Bellmanโ€“Ford ftw
๐Ÿ‘︎ 300
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/thirstyboye69
๐Ÿ“…︎ Apr 11 2019
๐Ÿšจ︎ report
[P] Implementation of DeepMind's Distributional Bellman and the C51 Algorithm flyyufelix.github.io/2017โ€ฆ
๐Ÿ‘︎ 17
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/hardmaru
๐Ÿ“…︎ Nov 02 2017
๐Ÿšจ︎ report
[Assignment 3] Bellman-Ford Expected Outputs

If you want to test your Bellman-Ford algorithm and want to know what the expected output is for each file:

https://preview.redd.it/zb8qc5ydgiz31.png?width=1568&format=png&auto=webp&s=6545e0d5509b882bffb8aa438b3dac1452c972ad

https://preview.redd.it/6hp8m80ggiz31.png?width=1590&format=png&auto=webp&s=281b86bd359e82c07101884f0903cdeca34f81ba

https://preview.redd.it/h3yis0dhgiz31.png?width=1528&format=png&auto=webp&s=9d3b26fa7c82975aa12ef68b50120fb6e6333d09

https://preview.redd.it/d4ke8vsigiz31.png?width=1553&format=png&auto=webp&s=8bd4479a0c11ed610c755e10442b62e7a5901bc8

I might make more testers later on (if I have time) and I'll post them here too

๐Ÿ‘︎ 30
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/knownoman
๐Ÿ“…︎ Nov 18 2019
๐Ÿšจ︎ report
After watching the โ€œHow Ford Solved the Crossover Problemโ€ video yesterday ๐Ÿ™„ Nice try algorithm, Iโ€™m not interested in purchasing lol
๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Clammy_fern
๐Ÿ“…︎ Jan 04 2022
๐Ÿšจ︎ report
Rusty Russell on lightning routing: Routing, Dijkstra, Bellman-Ford and BFG! medium.com/@rusty_lightniโ€ฆ
๐Ÿ‘︎ 63
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/thorjag
๐Ÿ“…︎ Jun 01 2016
๐Ÿšจ︎ report
Sรคger ni โ€en norsk, en tysk och Bellmanโ€ eller โ€en norsk, en tysk och *en* Bellman?โ€

Min รฅsikt รคr att alla som sรคger โ€en Bellmanโ€ bรถr tvรฅngsomhรคndertas av Svenska Akademien.

Diskutera i grupp och รฅterkom.

EDIT: Nationaliteter diskuterar vi imorgon.

๐Ÿ‘︎ 266
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Sealpoop_In_Profile
๐Ÿ“…︎ Jan 05 2022
๐Ÿšจ︎ report
A practical treatise on pairs trading, Bellman-Ford, Shannonโ€™s Demon, and order book pressure: Tales from 18 months of cryptocurrency arbitrage ddmckinnon.com/2019/04/24โ€ฆ
๐Ÿ‘︎ 5
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/dmckinno
๐Ÿ“…︎ May 07 2019
๐Ÿšจ︎ report
algo: is ford fulkerson algorithm the hardest thing to understand so far

i cant be the only one.

๐Ÿ‘︎ 18
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Far-Safety-1165
๐Ÿ“…︎ Oct 20 2021
๐Ÿšจ︎ report
ELI5: Bellman-Held-Karp algorithm process? For traveling salesman problem

I cannot find an easily consumable explanation of the process here, and how it manages to run faster than N! time for traveling sales person problem for a Hamiltonian cycle where shortest path S(s,v) where S is the start vertex and v is the destination vertex. But s=v

Starts and finishes at same vertex

๐Ÿ‘︎ 2
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/relaxus2maxus
๐Ÿ“…︎ Apr 24 2014
๐Ÿšจ︎ report
Bellman Ford with at most k-edges

Hello all,

I try to wrap my head around a extended version of the Bellman Ford shortest path algorithm. In k iterations the standard Bellman Ford algorithm can produce shortest path using more than k edges.

Here is a fairly naive idea that uses k-iterations of the standard algorithm:

  • In the i-th iteration only nodes that are not more than i edges away from the starting node, will be considered. Eg: In the first iteration only the nodes that are adjacent to the starting node, in the second iteration the nodes above plus the nodes that are adjacent to the prior.
  • Edge relaxation is only allowed when the resulting path does not use more edges.

This should be easy to implement. Do you think this will work, or are there any flaws that I have overseen?

๐Ÿ‘︎ 4
๐Ÿ’ฌ︎
๐Ÿ‘ค︎ u/Colonist666
๐Ÿ“…︎ Nov 13 2017
๐Ÿšจ︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.