What Edges Are Selected in the Bellman-Ford Algorithm?

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
Click For Summary
SUMMARY

The Bellman-Ford algorithm detects negative cycles in a graph by relaxing all edges repeatedly for |V|-1 iterations, where |V| is the number of vertices. Unlike Dijkstra's algorithm, which uses a priority queue to select the closest vertex, Bellman-Ford evaluates every edge in each iteration to potentially update the shortest path estimates. The process involves checking if the distance to the target node of each edge can be reduced, ensuring that all possible paths are considered for optimization.

PREREQUISITES
  • Understanding of graph theory concepts, particularly vertices and edges.
  • Familiarity with the Bellman-Ford algorithm and its purpose in pathfinding.
  • Knowledge of the concept of edge relaxation in algorithms.
  • Basic understanding of negative cycles in graphs.
NEXT STEPS
  • Study the implementation of the Bellman-Ford algorithm in Python.
  • Learn about the differences between Bellman-Ford and Dijkstra's algorithm.
  • Explore the concept of edge relaxation in detail.
  • Investigate real-world applications of the Bellman-Ford algorithm in network routing.
USEFUL FOR

Students, computer science enthusiasts, and software developers interested in graph algorithms and optimization techniques.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

I am reading an example about the Bellman-Ford algorithm in order to understand it, but I don't really know what edges we pick from the second step and at the following ones.

Here is the example I am looking at, where they want to detect if there is a negative cycle.

bf1.PNG


bf2.PNG


bf3.PNG


bf4.PNG


bf5.PNG


bf6.PNG

Could you explain to me the idea that we follow? (Thinking)
 
Physics news on Phys.org
evinda said:
I am reading an example about the Bellman-Ford algorithm in order to understand it, but I don't really know what edges we pick from the second step and at the following ones.

Here is the example I am looking at, where they want to detect if there is a negative cycle.

Could you explain to me the idea that we follow?

Hi evinda!

Wiki explains:
Like Dijkstra's algorithm, Bellman–Ford proceeds by relaxation, in which approximations to the correct distance are replaced by better ones until they eventually reach the solution. In both algorithms, the approximate distance to each vertex is always an overestimate of the true distance, and is replaced by the minimum of its old value and the length of a newly found path.

However, Dijkstra's algorithm uses a priority queue to greedily select the closest vertex that has not yet been processed, and performs this relaxation process on all of its outgoing edges; by contrast, the Bellman–Ford algorithm simply relaxes ''all'' the edges, and does this$|V|-1$ times, where $|V|$ is the number of vertices in the graph.


but I don't really know what edges we pick from the second step and at the following ones.

We pick all edges and see if we can make reduce the value of the target node of each edge. 🤔
 
Klaas van Aarsen said:
Hi evinda!

Wiki explains:
Like Dijkstra's algorithm, Bellman–Ford proceeds by relaxation, in which approximations to the correct distance are replaced by better ones until they eventually reach the solution. In both algorithms, the approximate distance to each vertex is always an overestimate of the true distance, and is replaced by the minimum of its old value and the length of a newly found path.

However, Dijkstra's algorithm uses a priority queue to greedily select the closest vertex that has not yet been processed, and performs this relaxation process on all of its outgoing edges; by contrast, the Bellman–Ford algorithm simply relaxes ''all'' the edges, and does this$|V|-1$ times, where $|V|$ is the number of vertices in the graph.

We pick all edges and see if we can make reduce the value of the target node of each edge. 🤔


I see... Thank you! (Mmm)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
  • · Replies 20 ·
Replies
20
Views
4K
  • · Replies 18 ·
Replies
18
Views
4K