// Nodos y tiempo de la búsqueda en los casos grandes. Una corrida de cada una, con -O2.
#include <chrono>
#include <iomanip>
#include <iostream>
#include <string>

#include "bound.h"
#include "geo.h"

namespace {

void row(const bound::Matrix& d, int n, const std::string& name, bound::Pruning pruning) {
    const auto start = std::chrono::steady_clock::now();
    const auto result = bound::solve(d, pruning);
    const std::chrono::duration<double> elapsed = std::chrono::steady_clock::now() - start;
    std::cout << std::setw(2) << n << "  " << std::left << std::setw(20) << name << std::right << std::setw(12)
              << result.nodes << std::setw(10) << std::fixed << std::setprecision(1)
              << static_cast<double>(result.cost) / 1000.0 << " km" << std::setw(9) << std::setprecision(2)
              << elapsed.count() << " s\n";
}

}  // namespace

int main() {
    const auto all = geo::read_places("capitales.csv");
    std::cout << " n  poda                       nodos       costo     tiempo\n";
    const auto d15 = geo::distance_matrix(geo::first_places(all, 15));
    row(d15, 15, "lo recorrido", bound::Pruning::partial);
    row(d15, 15, "con cota de árbol", bound::Pruning::spanning);
    row(geo::distance_matrix(geo::first_places(all, 20)), 20, "con cota de árbol", bound::Pruning::spanning);
    row(geo::distance_matrix(all), 26, "con cota de árbol", bound::Pruning::spanning);
}
