netoptim/neg_cycle.hpp file

Negative cycle detection for weighted directed graphs.

This module provides an efficient algorithm for detecting negative cycles in weighted directed graphs. It implements a cycle detection method that is superior to Bellman-Ford for this specific purpose.

The algorithm works by:

  1. Maintaining a predecessor map to track paths
  2. Performing edge relaxations iteratively
  3. Detecting cycles in the predecessor graph
  4. Verifying that detected cycles are indeed negative

Classes

template<typename DiGraph>
class NegCycleFinder
Negative cycle finder for weighted directed graphs.