negative_edge_cycle(graph, edge_cost_fn, /)#

Check if a negative cycle exists on a graph

This function will check for the existence of a negative cycle in a graph using the Bellman-Ford algorithm with the SPFA heuristic.

  • graph (PyDiGraph) – The input graph to use

  • edge_cost_fn – A python callable that will take in 1 parameter, an edge’s data object and will return a float that represents the cost of that edge.


True if there is a negative cycle or False otherwise

Return type: