Graph: (score ), (score ), (score ), (score ), . After negating: (), (), (), (). Run Bellman-Ford: after iterations, dist[2] = -12, dist[3] = -7, dist[4] = -4.
The -th iteration improves dist[3] (to ) and dist[4] (to ) due to cycle . Mark all nodes that improved and all nodes reachable from them.
Check two-way reachability: node (the cycle) is reachable from node (direct edge ). Node is reachable from node (direct edge ). Both checks pass. Output .