Let us create the following weighted graph 1 ( 0 ) -- -- -- -- -- -> ( 1 ) / | \ | | | - 1 | | - 1 | \ | / ( 3 ) < -- -- -- -- -- - ( 2 ) - 1
graph = [ [ 0 , 1 , INF , INF ] , [ INF , 0 , - 1 , INF ] , [ INF , INF , 0 , - 1 ] , [ - 1 , INF , INF , 0 ] ] NEW_LINE if ( negCyclefloydWarshall ( graph ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT