Function
check_negative_cycle
(
graph: list[dict[str, int]], distance: list[float], edge_count: int
)
Source from the content-addressed store, hash-verified
| 8 | |
| 9 | |
| 10 | def check_negative_cycle( |
| 11 | graph: list[dict[str, int]], distance: list[float], edge_count: int |
| 12 | ): |
| 13 | for j in range(edge_count): |
| 14 | u, v, w = (graph[j][k] for k in ["src", "dst", "weight"]) |
| 15 | if distance[u] != float("inf") and distance[u] + w < distance[v]: |
| 16 | return True |
| 17 | return False |
| 18 | |
| 19 | |
| 20 | def bellman_ford( |
Tested by
no test coverage detected