Every edge has three values ( u , v , w ) where the edge is from vertex u to v . And weight of the edge is w .
$ graph = array ( array ( 0 , 1 , -1 ) , array ( 0 , 2 , 4 ) , array ( 1 , 2 , 3 ) , array ( 1 , 3 , 2 ) , array ( 1 , 4 , 2 ) , array ( 3 , 2 , 5 ) , array ( 3 , 1 , 1 ) , array ( 4 , 3 , -3 ) ) ; BellmanFord ( $ graph , $ V , $ E , 0 ) ; ? >