def hasNegativeCycle(weight_matrix): n = len(weight_matrix) has_negative_cycle = False #missing code return has_negative_cycle weight_matrix = [[float('inf'), 5, 2], [5, float('inf'), -10], [2, -10, float('inf')]] print(hasNegativeCycle())
if cost[v][k] != float('inf') and cost[k][u] != float('inf') \ and (cost[v][k] + cost[k][u] < cost[v][u]): cost[v][u] = cost[v][k] + cost[k][u] path[v][u] = path[k][u]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)