// Cuántos nodos del árbol de búsqueda visita cada forma de podar, en las primeras filas de
// capitales.csv. Las tres dan el mismo costo; lo que cambia es el trabajo.
#include <iostream>
#include <string>

#include "../week-10/held_karp.h"
#include "bound.h"
#include "geo.h"

namespace {

std::string pad(const std::string& text, std::size_t width) {
    return std::string(width > text.size() ? width - text.size() : 0, ' ') + text;
}

std::string cell(const bound::Matrix& d, bound::Pruning pruning, int n, int up_to) {
    if (n > up_to) return "-";
    return std::to_string(bound::solve(d, pruning).nodes);
}

}  // namespace

int main() {
    const auto all = geo::read_places("capitales.csv");
    std::cout << " n  sin poda      lo recorrido  con cota de árbol  costo (m)\n";
    for (int n : {6, 8, 10, 11, 12, 13}) {
        const auto d = geo::distance_matrix(geo::first_places(all, n));
        std::cout << pad(std::to_string(n), 2) << pad(cell(d, bound::Pruning::none, n, 11), 10)
                  << pad(cell(d, bound::Pruning::partial, n, 13), 14)
                  << pad(cell(d, bound::Pruning::spanning, n, 13), 19)
                  << pad(std::to_string(bound::solve(d, bound::Pruning::spanning).cost), 11) << '\n';
    }
}
