added code for Bellman-Ford's algorithm