check for negative - weight cycles . The above step guarantees shortest distances if graph doesn 't contain  negative weight cycle. If we get a  shorter path, then there is a cycle.
for ( int i = 0 ; i < E ; i ++ ) { int x = graph [ i , 0 ] ; int y = graph [ i , 1 ] ; int weight = graph [ i , 2 ] ; if ( dis [ x ] != int . MaxValue && dis [ x ] + weight < dis [ y ] ) Console . WriteLine ( " Graph ▁ contains ▁ negative " + " ▁ weight ▁ cycle " ) ; } Console . WriteLine ( " Vertex ▁ Distance ▁ from ▁ Source " ) ; for ( int i = 0 ; i < V ; i ++ ) Console . WriteLine ( i + " TABSYMBOL TABSYMBOL " + dis [ i ] ) ; }