Files
reachability-algorithms/benchmark/decremental_bench.cc
2022-09-16 15:17:50 +03:00

34 lines
967 B
C++

#include <src/include/nanobench.h>
#include <doctest/doctest.h>
#include "algorithm/decremental_scc.h"
#include "algorithm/italiano.h"
#include "algorithm/frigioni.h"
#include "algorithm/tarjan.h"
#include <fstream>
using namespace graph;
TEST_SUITE("Decremental algorithms") {
TEST_CASE("Decremental maintenance of SCCs 1") {
std::ifstream infile("resources/dag.txt");
std::uint16_t u, v;
Digraph<std::uint16_t> G;
while (infile >> u >> v)
G.insert(u, v);
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjMatrix).execute();
// Testing whether an scc is a 1-vertex scc which after the normalization
// has no edges, in this case we know tgat there exist no 2-vertex sccs
for (auto& scc : SCCs) {
CHECK_EQ(std::all_of(scc.adjMatrix.begin(), scc.adjMatrix.end(),
[](const auto& p) {
return p.second.size() == 0;
}), true);
}
}
}