The main function that finds shortest distances from src to all other vertices using Bellman - Ford algorithm . The function also detects negative weight cycle The row graph [ i ] represents i - th edge with three values u , v and w .
< ? php function BellmanFord ( $ graph , $ V , $ E , $ src ) {