Here is the basic implementation:
function bellmanFord(n, edges, source):
dist = array of size n, all infinity
dist[source] = 0
for round from 1 to n - 1:
for (u, v, w) in edges:
if dist[u] + w < dist[v]:
dist[v] = dist[u] + w
return dist
After iterations, dist[v] contains the shortest distance from source to , assuming no negative cycles. If a negative cycle exists, some distances might be incorrect, but you can detect this with one more iteration.
This runs in time and uses space.