Graph: (score ), (score ), (score ), (score ), . After negating: (), (), (), (). Run Bellman-Ford: after iterations, dist[2] = -3, dist[3] = -7, dist[4] = -4.
The -th iteration improves dist[2] and dist[3] indefinitely due to cycle . Node is reachable from node , which is in the cycle. Mark in_cycle[4] = True. Output because room is affected by the positive cycle.