# modify the Bellman-Ford algorithm

Not what you're looking for? Search our solutions OR ask your own Custom question.

Show how to modify the Bellman-Ford algorithm to find and print a negative weight cycle (reachable from the source, s) in a weighted directed graph G if one exists. If there is no negative weight cycle, your algorithm should print out "no negative weight cycle reachable from". If there is a negative weight cycle reachable from the source vertex, your algorithm should display one such cycle.

Â© BrainMass Inc. brainmass.com December 24, 2021, 4:59 pm ad1c9bdddfhttps://brainmass.com/computer-science/arrays/modifying-bellman-ford-algorithm-20214

#### Solution Preview

for v in V

d[v]=infinity

d[s] = 0

for (i = 1 to |V|-1)

for each (u,v) in E

if (d[v] > d[u] + w(u, v))

d[v]=d[u] + w(u, v)

parent[v] = u

for ...

#### Solution Summary

This solution suggests ideas to modify the Bellman-Ford algorithm are included.

$2.49