Reconstruct only the deconstructed SCC
This commit is contained in:
@@ -18,7 +18,7 @@ public:
|
|||||||
void init() override;
|
void init() override;
|
||||||
|
|
||||||
//
|
//
|
||||||
void findSCC();
|
void findSCC(graph::Digraph<T> G);
|
||||||
|
|
||||||
// Return true if u and v are in the same SCC
|
// Return true if u and v are in the same SCC
|
||||||
bool query(const T& u, const T& v) override;
|
bool query(const T& u, const T& v) override;
|
||||||
@@ -44,12 +44,12 @@ private:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void RodittyZwick<T>::init() {
|
void RodittyZwick<T>::init() {
|
||||||
findSCC();
|
findSCC(this->G);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void RodittyZwick<T>::findSCC() {
|
void RodittyZwick<T>::findSCC(graph::Digraph<T> G) {
|
||||||
auto SCCs = Tarjan<T>(this->G.adjList).execute();
|
auto SCCs = Tarjan<T>(G.adjList).execute();
|
||||||
|
|
||||||
for (auto& SCC : SCCs) {
|
for (auto& SCC : SCCs) {
|
||||||
const auto& w = SCC.id;
|
const auto& w = SCC.id;
|
||||||
@@ -95,7 +95,7 @@ void RodittyZwick<T>::remove(const T& u, const T& v) {
|
|||||||
|
|
||||||
// If a SCC is broken, compute all SCCs again
|
// If a SCC is broken, compute all SCCs again
|
||||||
if (!In[w].adjList.count(u) || !Out[w].adjList.count(v))
|
if (!In[w].adjList.count(u) || !Out[w].adjList.count(v))
|
||||||
findSCC();
|
findSCC(C[w]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // namespace algo
|
}; // namespace algo
|
||||||
|
|||||||
Reference in New Issue
Block a user