Template Class negCycleFinder

Template Parameter Order

  1. typename Graph

Class Documentation

template<typename Graph>
class negCycleFinder

negative cycle

Negative cycle detection for weighed graphs.

  1. BF needs a source node.

  2. BF detect whether there is a negative cycle at the fianl stage.

  3. BF restarts the solution (dist[u]) every time.

Template Parameters

Graph – Note: Bellman-Ford’s shortest-path algorithm (BF) is NOT the best way to detect negative cycles, because

Public Functions

inline explicit negCycleFinder(const Graph &G)

Construct a new neg Cycle Finder object.

Parameters

G[in]

template<typename Container, typename WeightFn>
inline auto find_neg_cycle(Container &&dist, WeightFn &&get_weight) -> std::vector<edge_t>

find negative cycle

Template Parameters
  • Container

  • WeightFn

Parameters
  • dist[inout]

  • get_weight[in]

Returns

std::vector<edge_t>