Example #1
0
void print_accepted(const util::NodeRange& nodes,
                    std::function<bool(Node, Node)> is_strong,
                    std::function<bool(Node)> is_root)
{
    using util::fmt;
    using std::endl;
    using std::cout;

    auto count_parents = [&](const auto N) {
        using boost::count_if;
        using common::pars;

        auto has_n_parents = [&](auto node) {
            auto is_accepted = [&](auto par) { return is_strong(par, node); };

            return !is_root(node) && count_if(pars(node), is_accepted) == N;
        };
        return count_if(nodes, has_n_parents);
    };

    auto W = static_cast<floating_t>(nodes.size()) / 100.;

    cout << "0 parents accepted: " << fmt(count_parents(0) / W) << "%" << endl;
    cout << "1 parents accepted: " << fmt(count_parents(1) / W) << "%" << endl;
    cout << "2 parents accepted: " << fmt(count_parents(2) / W) << "%" << endl;
    cout << "3 parents accepted: " << fmt(count_parents(3) / W) << "%" << endl;
    cout << "4 parents accepted: " << fmt(count_parents(4) / W) << "%" << endl;
}
Example #2
0
void print_roots(const util::NodeRange& nodes,
                 std::function<bool(Node)> is_root)
{
    using boost::count_if;
    assert(nodes.size() > 0);

    auto num_roots = count_if(nodes, is_root);

    std::cout << "             roots: ";
    const auto pcnt = (num_roots * 100.) / nodes.size();
    std::cout << num_roots << "(" << util::fmt(pcnt, 5) << "%)";
    std::cout << std::endl;
}