Add Eext removal in frigioni and tests
This commit is contained in:
@@ -94,7 +94,6 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
std::vector<std::pair<T, T>> Eint;
|
||||
std::vector<std::pair<T, T>> Eext;
|
||||
|
||||
// Put incoming edge removal requests in the corresponding collection
|
||||
for (const auto& [u, v] : edges) {
|
||||
if (rodittyZwick.query(u, v))
|
||||
Eint.push_back({ u, v });
|
||||
@@ -103,25 +102,40 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
}
|
||||
|
||||
std::map<T, std::stack<T>> H;
|
||||
|
||||
// Handle SCC internal edge removals
|
||||
for (const auto& [u, v] : Eint) {
|
||||
this->G.remove(u, v);
|
||||
rodittyZwick.remove(u, v);
|
||||
|
||||
if (!rodittyZwick.query(u, v)) {
|
||||
TC[u][v] = false;
|
||||
auto C = rodittyZwick.getSCCs();
|
||||
auto D = E[u]; // or E[v], the component that's been split
|
||||
E.erase(u);
|
||||
|
||||
E[C[u].id].inc.erase({ u, v });
|
||||
E[C[u].id].out.erase({ u, v });
|
||||
E[C[u].id].in.erase({ u, v });
|
||||
auto D = E[C[u].id];
|
||||
E.erase(C[u].id);
|
||||
|
||||
for (const auto& id : std::views::keys(C)) {
|
||||
if (RT[id].contains(id, v)) {
|
||||
if (E[C[v].id].inc.size() > 1)
|
||||
H[id].push(C[v].id);
|
||||
else {
|
||||
for (const auto& w : C[id].vertices())
|
||||
TC[w][v] = false;
|
||||
for (const auto& c : E[v].out)
|
||||
H[id].push(C[c.second].id);
|
||||
}
|
||||
RT[id].adjMatrix[u].erase(v);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& [w, z] : D.inc) {
|
||||
E[C[z].id].inc.insert({ w, z });
|
||||
// check if scc needs hook
|
||||
}
|
||||
|
||||
for (const auto& [w, z] : D.out) {
|
||||
E[C[z].id].out.insert({ w, z });
|
||||
// check if scc needs hook
|
||||
E[C[w].id].out.insert({ w, z });
|
||||
}
|
||||
|
||||
for (const auto& [w, z] : D.in) {
|
||||
@@ -137,13 +151,26 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
}
|
||||
}
|
||||
|
||||
// Handle SCC external edge removals
|
||||
for (const auto& [u, v] : Eext) {
|
||||
this->G.remove(u, v);
|
||||
// TODO
|
||||
auto C = rodittyZwick.getSCCs();
|
||||
|
||||
for (const auto& id : std::views::keys(C)) {
|
||||
if (RT[id].contains(id, v)) {
|
||||
if (E[C[v].id].inc.size() > 1)
|
||||
H[id].push(C[v].id);
|
||||
else {
|
||||
for (const auto& w : C[id].vertices())
|
||||
TC[w][v] = false;
|
||||
for (const auto& c : E[v].out)
|
||||
H[id].push(C[c.second].id);
|
||||
}
|
||||
RT[id].adjMatrix[u].erase(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Repair the trees
|
||||
auto C = rodittyZwick.getSCCs();
|
||||
for (const auto& id : std::views::keys(rodittyZwick.getSCCs())) {
|
||||
while (H[id].size() > 0) {
|
||||
const auto& h = H[id].top();
|
||||
@@ -158,7 +185,10 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
|
||||
}
|
||||
H[id].pop();
|
||||
if (!found) {
|
||||
TC[id][h] = false;
|
||||
auto C = rodittyZwick.getSCCs();
|
||||
for (const auto& w : C[id].vertices())
|
||||
TC[w][h] = false;
|
||||
|
||||
for (const auto& [u, v] : E[h].out) {
|
||||
H[id].push(v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user