:github_url: https://github.com/svenevs/exhale-companion .. _program_listing_file_netoptim_parametric.hpp: Program Listing for File parametric.hpp ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``netoptim/parametric.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // -*- coding: utf-8 -*- #pragma once #include "neg_cycle.hpp" // import negCycleFinder // #include #include #include template auto max_parametric(const Graph& G, T& r_opt, Fn1&& d, Fn2&& zero_cancel, Container&& dist, size_t max_iter = 1000) { using edge_t = typename Graph::edge_t; auto get_weight = [&](const edge_t& e) -> T { // int??? return d(r_opt, e); }; auto S = negCycleFinder(G); auto C_opt = std::vector {}; // should initial outside auto niter = 0U; for (; niter != max_iter; ++niter) { const auto& C_min = S.find_neg_cycle(std::forward(dist), get_weight); if (C_min.empty()) { break; } const auto& r_min = zero_cancel(C_min); if (r_min >= r_opt) { break; } C_opt = C_min; r_opt = r_min; // update ??? for (auto&& edge : C_opt) { const auto e = G.end_points(edge); dist[e.first] = dist[e.second] - get_weight(edge); } } return C_opt; }