Refactor: Rename adjMatrix to adjList
This commit is contained in:
@@ -14,8 +14,8 @@ class BreadthFirstSearch {
|
|||||||
public:
|
public:
|
||||||
BreadthFirstSearch() = default;
|
BreadthFirstSearch() = default;
|
||||||
|
|
||||||
BreadthFirstSearch(std::map<T, std::set<T>> adjMatrix)
|
BreadthFirstSearch(std::map<T, std::set<T>> adjList)
|
||||||
: adjMatrix(adjMatrix) {}
|
: adjList(adjList) {}
|
||||||
|
|
||||||
// Traverse whole graph using the BFS search, and save the tree graph
|
// Traverse whole graph using the BFS search, and save the tree graph
|
||||||
// which is created when visiting new vertices (Breadth First Tree)
|
// which is created when visiting new vertices (Breadth First Tree)
|
||||||
@@ -25,7 +25,7 @@ public:
|
|||||||
bool query(const T& root, const T& target);
|
bool query(const T& root, const T& target);
|
||||||
private:
|
private:
|
||||||
// Represents the graph on which the algorithm will be executed
|
// Represents the graph on which the algorithm will be executed
|
||||||
std::map<T, std::set<T>> adjMatrix;
|
std::map<T, std::set<T>> adjList;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -40,7 +40,7 @@ std::map<T, std::set<T>> BreadthFirstSearch<T>::execute(const T& root) {
|
|||||||
const auto v = Q.front();
|
const auto v = Q.front();
|
||||||
Q.pop();
|
Q.pop();
|
||||||
|
|
||||||
for (const auto& u : adjMatrix[v]) {
|
for (const auto& u : adjList[v]) {
|
||||||
if (!visited[u]) {
|
if (!visited[u]) {
|
||||||
visited[u] = true;
|
visited[u] = true;
|
||||||
tree[v].insert(u);
|
tree[v].insert(u);
|
||||||
@@ -65,7 +65,7 @@ bool BreadthFirstSearch<T>::query(const T& root, const T& target) {
|
|||||||
|
|
||||||
if (v == target) return true;
|
if (v == target) return true;
|
||||||
|
|
||||||
for (const auto& u : adjMatrix[v]) {
|
for (const auto& u : adjList[v]) {
|
||||||
if (!visited[u]) {
|
if (!visited[u]) {
|
||||||
visited[u] = true;
|
visited[u] = true;
|
||||||
Q.push(u);
|
Q.push(u);
|
||||||
|
|||||||
@@ -50,14 +50,14 @@ private:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Frigioni<T>::init() {
|
void Frigioni<T>::init() {
|
||||||
auto SCCs = Tarjan<T>(this->G.adjMatrix).execute();
|
auto SCCs = Tarjan<T>(this->G.adjList).execute();
|
||||||
rodittyZwick = RodittyZwick<T>(this->G);
|
rodittyZwick = RodittyZwick<T>(this->G);
|
||||||
rodittyZwick.init();
|
rodittyZwick.init();
|
||||||
|
|
||||||
for (auto& scc : SCCs) {
|
for (auto& scc : SCCs) {
|
||||||
RT[scc.id] = BreadthFirstTree<T>(this->G, scc.id);
|
RT[scc.id] = BreadthFirstTree<T>(this->G, scc.id);
|
||||||
for (const auto& u : this->G.vertices()) {
|
for (const auto& u : this->G.vertices()) {
|
||||||
for (const auto& v : this->G.adjMatrix[u]) {
|
for (const auto& v : this->G.adjList[u]) {
|
||||||
if (scc.member(u)) {
|
if (scc.member(u)) {
|
||||||
if (scc.member(v))
|
if (scc.member(v))
|
||||||
E[scc.id].in.insert(std::make_pair(u, v));
|
E[scc.id].in.insert(std::make_pair(u, v));
|
||||||
@@ -126,7 +126,7 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
|||||||
for (const auto& c : E[v].out)
|
for (const auto& c : E[v].out)
|
||||||
H[id].push(C[c.second].id);
|
H[id].push(C[c.second].id);
|
||||||
}
|
}
|
||||||
RT[id].adjMatrix[u].erase(v);
|
RT[id].adjList[u].erase(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
|||||||
for (const auto& c : E[v].out)
|
for (const auto& c : E[v].out)
|
||||||
H[id].push(C[c.second].id);
|
H[id].push(C[c.second].id);
|
||||||
}
|
}
|
||||||
RT[id].adjMatrix[u].erase(v);
|
RT[id].adjList[u].erase(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
|||||||
|
|
||||||
for (const auto& [u, v] : E[h].inc) {
|
for (const auto& [u, v] : E[h].inc) {
|
||||||
if (RT[id].contains(id, u)) {
|
if (RT[id].contains(id, u)) {
|
||||||
RT[id].adjMatrix[u].insert(h);
|
RT[id].adjList[u].insert(h);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ bool HenzingerKing<T>::query(const T& u, const T& v) {
|
|||||||
|
|
||||||
return std::any_of(S.begin(), S.end(),
|
return std::any_of(S.begin(), S.end(),
|
||||||
[&](const T& w) {
|
[&](const T& w) {
|
||||||
return In[w].adjMatrix.contains(u) &&
|
return In[w].adjList.contains(u) &&
|
||||||
Out[w].adjMatrix.contains(v);
|
Out[w].adjList.contains(v);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ private:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void Italiano<T>::init() {
|
void Italiano<T>::init() {
|
||||||
for (const auto& u : this->G.vertices()) {
|
for (const auto& u : this->G.vertices()) {
|
||||||
for (const auto& v : this->G.adjMatrix[u]) {
|
for (const auto& v : this->G.adjList[u]) {
|
||||||
E[v].inc.insert(u);
|
E[v].inc.insert(u);
|
||||||
E[u].out.insert(v);
|
E[u].out.insert(v);
|
||||||
TC[u][v] = false;
|
TC[u][v] = false;
|
||||||
@@ -66,7 +66,7 @@ bool Italiano<T>::query(const T& u, const T& v) {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Italiano<T>::remove(const T& u, const T& v) {
|
void Italiano<T>::remove(const T& u, const T& v) {
|
||||||
if (!this->G.adjMatrix[u].contains(v)) return;
|
if (!this->G.adjList[u].contains(v)) return;
|
||||||
|
|
||||||
std::map<T, std::stack<T>> H;
|
std::map<T, std::stack<T>> H;
|
||||||
for (const auto& w : this->G.vertices()) {
|
for (const auto& w : this->G.vertices()) {
|
||||||
@@ -78,7 +78,7 @@ void Italiano<T>::remove(const T& u, const T& v) {
|
|||||||
for (const auto& c : E[v].out)
|
for (const auto& c : E[v].out)
|
||||||
H[w].push(c);
|
H[w].push(c);
|
||||||
}
|
}
|
||||||
RT[w].adjMatrix[u].erase(v);
|
RT[w].adjList[u].erase(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
E[u].out.erase(v);
|
E[u].out.erase(v);
|
||||||
@@ -97,7 +97,7 @@ void Italiano<T>::repairTrees(std::map<T, std::stack<T>>& H) {
|
|||||||
|
|
||||||
for (const auto& i : E[h].inc) {
|
for (const auto& i : E[h].inc) {
|
||||||
if (RT[z].contains(z, i)) {
|
if (RT[z].contains(z, i)) {
|
||||||
RT[z].adjMatrix[i].insert(h);
|
RT[z].adjList[i].insert(h);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void RodittyZwick<T>::init() {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void RodittyZwick<T>::findSCC() {
|
void RodittyZwick<T>::findSCC() {
|
||||||
auto SCCs = Tarjan<T>(this->G.adjMatrix).execute();
|
auto SCCs = Tarjan<T>(this->G.adjList).execute();
|
||||||
|
|
||||||
for (auto& SCC : SCCs) {
|
for (auto& SCC : SCCs) {
|
||||||
const auto& w = SCC.id;
|
const auto& w = SCC.id;
|
||||||
@@ -78,8 +78,8 @@ void RodittyZwick<T>::remove(const T& u, const T& v) {
|
|||||||
if (A[u] != A[v]) return;
|
if (A[u] != A[v]) return;
|
||||||
|
|
||||||
// If edge (u,v) is not contained in both inTree and outTree do nothing
|
// If edge (u,v) is not contained in both inTree and outTree do nothing
|
||||||
if (!In[w].adjMatrix[u].contains(v) &&
|
if (!In[w].adjList[u].contains(v) &&
|
||||||
!Out[w].adjMatrix[u].contains(v))
|
!Out[w].adjList[u].contains(v))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update In(w) and Out(w)
|
// Update In(w) and Out(w)
|
||||||
@@ -87,7 +87,7 @@ void RodittyZwick<T>::remove(const T& u, const T& v) {
|
|||||||
In[w] = BreadthFirstTree<T>(C[w].reverse(), w);
|
In[w] = BreadthFirstTree<T>(C[w].reverse(), w);
|
||||||
|
|
||||||
// If a SCC is broken, compute all SCCs again
|
// If a SCC is broken, compute all SCCs again
|
||||||
if (!In[w].adjMatrix.count(u) || !Out[w].adjMatrix.count(v))
|
if (!In[w].adjList.count(u) || !Out[w].adjList.count(v))
|
||||||
findSCC();
|
findSCC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Tarjan {
|
|||||||
public:
|
public:
|
||||||
Tarjan() = default;
|
Tarjan() = default;
|
||||||
|
|
||||||
Tarjan(std::map<T, std::set<T>> adjMatrix) : adjMatrix(adjMatrix) {}
|
Tarjan(std::map<T, std::set<T>> adjList) : adjList(adjList) {}
|
||||||
|
|
||||||
//
|
//
|
||||||
auto execute();
|
auto execute();
|
||||||
@@ -24,7 +24,7 @@ public:
|
|||||||
//
|
//
|
||||||
void strongConnect(const T& u);
|
void strongConnect(const T& u);
|
||||||
private:
|
private:
|
||||||
std::map<T, std::set<T>> adjMatrix;
|
std::map<T, std::set<T>> adjList;
|
||||||
std::stack<T> S;
|
std::stack<T> S;
|
||||||
std::int16_t index = 0;
|
std::int16_t index = 0;
|
||||||
std::vector<SCC<T>> SCCs;
|
std::vector<SCC<T>> SCCs;
|
||||||
@@ -44,7 +44,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
|||||||
S.push(u);
|
S.push(u);
|
||||||
vmap[u].onStack = true;
|
vmap[u].onStack = true;
|
||||||
|
|
||||||
for (const auto& w : adjMatrix[u]) {
|
for (const auto& w : adjList[u]) {
|
||||||
if (vmap[w].index == -1) {
|
if (vmap[w].index == -1) {
|
||||||
strongConnect(w);
|
strongConnect(w);
|
||||||
vmap[u].lowlink = std::min(vmap[u].lowlink, vmap[w].lowlink);
|
vmap[u].lowlink = std::min(vmap[u].lowlink, vmap[w].lowlink);
|
||||||
@@ -63,7 +63,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
|||||||
const auto w = S.top();
|
const auto w = S.top();
|
||||||
S.pop();
|
S.pop();
|
||||||
vmap[w].onStack = false;
|
vmap[w].onStack = false;
|
||||||
scc[w] = adjMatrix[w];
|
scc[w] = adjList[w];
|
||||||
finished = (w == u);
|
finished = (w == u);
|
||||||
} while (!finished);
|
} while (!finished);
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
auto Tarjan<T>::execute() {
|
auto Tarjan<T>::execute() {
|
||||||
for (const auto& u : std::views::keys(adjMatrix)) {
|
for (const auto& u : std::views::keys(adjList)) {
|
||||||
if (vmap[u].index == -1)
|
if (vmap[u].index == -1)
|
||||||
strongConnect(u);
|
strongConnect(u);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
BreadthFirstTree<T>::BreadthFirstTree(Digraph<T> G, T root) {
|
BreadthFirstTree<T>::BreadthFirstTree(Digraph<T> G, T root) {
|
||||||
this->adjMatrix = algo::BreadthFirstSearch<T>(G.adjMatrix).execute(root);
|
this->adjList = algo::BreadthFirstSearch<T>(G.adjList).execute(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace graph
|
} // namespace graph
|
||||||
|
|||||||
@@ -28,23 +28,23 @@ public:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Digraph<T>::Digraph(std::map<T, std::set<T>> G) {
|
Digraph<T>::Digraph(std::map<T, std::set<T>> G) {
|
||||||
this->adjMatrix = G;
|
this->adjList = G;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Digraph<T>::contains(const T& u, const T& v) {
|
bool Digraph<T>::contains(const T& u, const T& v) {
|
||||||
return algo::BreadthFirstSearch<T>(this->adjMatrix).query(u, v);
|
return algo::BreadthFirstSearch<T>(this->adjList).query(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Digraph<T>::insert(const T& u, const T& v) {
|
void Digraph<T>::insert(const T& u, const T& v) {
|
||||||
this->adjMatrix[u].insert(v);
|
this->adjList[u].insert(v);
|
||||||
this->adjMatrix[v];
|
this->adjList[v];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Digraph<T>::remove(const T& u, const T& v) {
|
void Digraph<T>::remove(const T& u, const T& v) {
|
||||||
this->adjMatrix[u].erase(v);
|
this->adjList[u].erase(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -52,7 +52,7 @@ auto Digraph<T>::reverse() {
|
|||||||
std::map<T, std::set<T>> revMatrix;
|
std::map<T, std::set<T>> revMatrix;
|
||||||
|
|
||||||
for (const auto& u : this->vertices()) {
|
for (const auto& u : this->vertices()) {
|
||||||
for (const auto& v : this->adjMatrix[u]) {
|
for (const auto& v : this->adjList[u]) {
|
||||||
revMatrix[v].insert(u);
|
revMatrix[v].insert(u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,31 +36,31 @@ public:
|
|||||||
std::uint16_t E();
|
std::uint16_t E();
|
||||||
|
|
||||||
// Adjacency matrix representation
|
// Adjacency matrix representation
|
||||||
std::map<T, std::set<T>> adjMatrix;
|
std::map<T, std::set<T>> adjList;
|
||||||
|
|
||||||
friend std::ostream& operator<<<>(std::ostream& os, Graph<T>& G);
|
friend std::ostream& operator<<<>(std::ostream& os, Graph<T>& G);
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Graph<T>::~Graph() {
|
Graph<T>::~Graph() {
|
||||||
adjMatrix.clear();
|
adjList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
auto Graph<T>::vertices() {
|
auto Graph<T>::vertices() {
|
||||||
return std::views::keys(adjMatrix);
|
return std::views::keys(adjList);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::uint16_t Graph<T>::V() {
|
std::uint16_t Graph<T>::V() {
|
||||||
return static_cast<std::uint16_t>(adjMatrix.size());
|
return static_cast<std::uint16_t>(adjList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::uint16_t Graph<T>::E() {
|
std::uint16_t Graph<T>::E() {
|
||||||
std::uint16_t edges = 0;
|
std::uint16_t edges = 0;
|
||||||
for (const auto& u : vertices()) {
|
for (const auto& u : vertices()) {
|
||||||
edges += static_cast<std::uint16_t>(adjMatrix[u].size());
|
edges += static_cast<std::uint16_t>(adjList[u].size());
|
||||||
}
|
}
|
||||||
return static_cast<std::uint16_t>(edges);
|
return static_cast<std::uint16_t>(edges);
|
||||||
}
|
}
|
||||||
@@ -69,8 +69,8 @@ template<typename T>
|
|||||||
std::ostream& operator<<(std::ostream& os, Graph<T>& G) {
|
std::ostream& operator<<(std::ostream& os, Graph<T>& G) {
|
||||||
os << "V: " << G.V() << " E: " << G.E() << '\n';
|
os << "V: " << G.V() << " E: " << G.E() << '\n';
|
||||||
for (const auto& u : this->vertices()) {
|
for (const auto& u : this->vertices()) {
|
||||||
if (!this->adjMatrix[u].empty()) {
|
if (!this->adjList[u].empty()) {
|
||||||
for (const auto& v : this->adjMatrix[u]) {
|
for (const auto& v : this->adjList[u]) {
|
||||||
os << u << "->" << v << ' ';
|
os << u << "->" << v << ' ';
|
||||||
}
|
}
|
||||||
os << '\n';
|
os << '\n';
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ private:
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void SCC<T>::normalize() {
|
void SCC<T>::normalize() {
|
||||||
for (const auto& u : this->vertices()) {
|
for (const auto& u : this->vertices()) {
|
||||||
for (const auto& v : this->adjMatrix[u]) {
|
for (const auto& v : this->adjList[u]) {
|
||||||
if (!this->adjMatrix.count(v)) {
|
if (!this->adjList.count(v)) {
|
||||||
this->adjMatrix[u].erase(v);
|
this->adjList[u].erase(v);
|
||||||
this->adjMatrix.erase(v);
|
this->adjList.erase(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ TEST_SUITE("Algorithm") {
|
|||||||
G.insert(13, 9);
|
G.insert(13, 9);
|
||||||
G.insert(12, 10);
|
G.insert(12, 10);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 13);
|
REQUIRE_EQ(G.V(), 13);
|
||||||
|
|
||||||
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjMatrix).execute();
|
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjList).execute();
|
||||||
|
|
||||||
std::vector<std::vector<std::uint16_t>> expected = {
|
std::vector<std::vector<std::uint16_t>> expected = {
|
||||||
{9, 10, 11, 12, 13},
|
{9, 10, 11, 12, 13},
|
||||||
@@ -51,7 +51,7 @@ TEST_SUITE("Algorithm") {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (auto i = 0; i < SCCs.size(); i++) {
|
for (auto i = 0; i < SCCs.size(); i++) {
|
||||||
auto kv = std::views::keys(SCCs[i].adjMatrix);
|
auto kv = std::views::keys(SCCs[i].adjList);
|
||||||
CHECK_EQ(std::is_permutation(kv.begin(), kv.end(),
|
CHECK_EQ(std::is_permutation(kv.begin(), kv.end(),
|
||||||
expected[i].begin()), true);
|
expected[i].begin()), true);
|
||||||
}
|
}
|
||||||
@@ -67,12 +67,12 @@ TEST_SUITE("Algorithm") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjMatrix).execute();
|
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjList).execute();
|
||||||
|
|
||||||
// Testing whether an scc is a 1-vertex scc which after the normalization
|
// 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
|
// has no edges, in this case we know tgat there exist no 2-vertex sccs
|
||||||
for (auto& scc : SCCs) {
|
for (auto& scc : SCCs) {
|
||||||
CHECK_EQ(std::all_of(scc.adjMatrix.begin(), scc.adjMatrix.end(),
|
CHECK_EQ(std::all_of(scc.adjList.begin(), scc.adjList.end(),
|
||||||
[](const auto& p) {
|
[](const auto& p) {
|
||||||
return p.second.size() == 0;
|
return p.second.size() == 0;
|
||||||
}), true);
|
}), true);
|
||||||
@@ -107,7 +107,7 @@ TEST_SUITE("Algorithm") {
|
|||||||
G.insert(12, 10);
|
G.insert(12, 10);
|
||||||
|
|
||||||
auto tree =
|
auto tree =
|
||||||
algo::BreadthFirstSearch<std::uint16_t>(G.adjMatrix).execute(1);
|
algo::BreadthFirstSearch<std::uint16_t>(G.adjList).execute(1);
|
||||||
|
|
||||||
std::map<std::uint16_t, std::set<std::uint16_t>> expected = {
|
std::map<std::uint16_t, std::set<std::uint16_t>> expected = {
|
||||||
{1, {2}},
|
{1, {2}},
|
||||||
@@ -155,7 +155,7 @@ TEST_SUITE("Algorithm") {
|
|||||||
G.insert(13, 9);
|
G.insert(13, 9);
|
||||||
G.insert(12, 10);
|
G.insert(12, 10);
|
||||||
|
|
||||||
algo::BreadthFirstSearch<std::uint16_t> bfs(G.adjMatrix);
|
algo::BreadthFirstSearch<std::uint16_t> bfs(G.adjList);
|
||||||
|
|
||||||
CHECK_EQ(bfs.query(1, 5), true);
|
CHECK_EQ(bfs.query(1, 5), true);
|
||||||
CHECK_EQ(bfs.query(1, 10), true);
|
CHECK_EQ(bfs.query(1, 10), true);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ TEST_SUITE("Decremental Reachability Test") {
|
|||||||
G.insert(8, 9);
|
G.insert(8, 9);
|
||||||
G.insert(9, 5);
|
G.insert(9, 5);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
algo::RodittyZwick<std::uint16_t> rodittyZwick(G);
|
algo::RodittyZwick<std::uint16_t> rodittyZwick(G);
|
||||||
rodittyZwick.init();
|
rodittyZwick.init();
|
||||||
@@ -85,7 +85,7 @@ TEST_SUITE("Decremental Reachability Test") {
|
|||||||
G.insert(7, 9);
|
G.insert(7, 9);
|
||||||
G.insert(8, 9);
|
G.insert(8, 9);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
algo::Italiano<std::uint16_t> italiano(G);
|
algo::Italiano<std::uint16_t> italiano(G);
|
||||||
italiano.init();
|
italiano.init();
|
||||||
@@ -142,7 +142,7 @@ TEST_SUITE("Decremental Reachability Test") {
|
|||||||
G.insert(8, 9);
|
G.insert(8, 9);
|
||||||
G.insert(9, 5);
|
G.insert(9, 5);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
algo::Frigioni<std::uint16_t> frigioni(G);
|
algo::Frigioni<std::uint16_t> frigioni(G);
|
||||||
frigioni.init();
|
frigioni.init();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ TEST_SUITE("Dynamic Reachability Test") {
|
|||||||
G.insert(7, 9);
|
G.insert(7, 9);
|
||||||
G.insert(8, 9);
|
G.insert(8, 9);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
algo::King<std::uint16_t> king(G);
|
algo::King<std::uint16_t> king(G);
|
||||||
king.init();
|
king.init();
|
||||||
@@ -92,7 +92,7 @@ TEST_SUITE("Dynamic Reachability Test") {
|
|||||||
G.insert(8, 9);
|
G.insert(8, 9);
|
||||||
G.insert(9, 5);
|
G.insert(9, 5);
|
||||||
|
|
||||||
REQUIRE_EQ(G.adjMatrix.size(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
algo::HenzingerKing<std::uint16_t> henzingerKing(G);
|
algo::HenzingerKing<std::uint16_t> henzingerKing(G);
|
||||||
henzingerKing.init();
|
henzingerKing.init();
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ TEST_SUITE("Graph") {
|
|||||||
|
|
||||||
REQUIRE_EQ(G.V(), 9);
|
REQUIRE_EQ(G.V(), 9);
|
||||||
|
|
||||||
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjMatrix).execute();
|
auto SCCs = algo::Tarjan<std::uint16_t>(G.adjList).execute();
|
||||||
|
|
||||||
std::vector<std::vector<std::uint16_t>> expected = {
|
std::vector<std::vector<std::uint16_t>> expected = {
|
||||||
{5, 6, 7, 8, 9},
|
{5, 6, 7, 8, 9},
|
||||||
|
|||||||
Reference in New Issue
Block a user