60 lines
1000 B
C++
60 lines
1000 B
C++
#ifndef ITALIANO_H_
|
|
#define ITALIANO_H_
|
|
|
|
#include "algorithm/roditty_zwick.h"
|
|
#include "algorithm/tarjan.h"
|
|
#include "tree/breadth_first_tree.h"
|
|
|
|
#include <forward_list>
|
|
|
|
using namespace graph;
|
|
using namespace tree;
|
|
|
|
namespace algo {
|
|
|
|
template<typename T>
|
|
class Italiano : public RodittyZwick<T> {
|
|
public:
|
|
Italiano(Digraph<T> G) : G(G) {}
|
|
|
|
void init();
|
|
|
|
bool query(const T& u, const T& v);
|
|
|
|
void remove(const T& u, const T& v);
|
|
private:
|
|
Digraph<T> G;
|
|
|
|
// Connect each vertex with its representative SCC
|
|
std::map<T, SCC<T>> TC;
|
|
|
|
// Reachability trees
|
|
std::map<T, std::set<T>> RT;
|
|
|
|
// Incoming / Outgoing edges
|
|
struct Edges {
|
|
std::forward_list<T> Ein;
|
|
std::forward_list<T> Eout;
|
|
};
|
|
std::map<SCC<T>, Edges> E;
|
|
};
|
|
|
|
|
|
template<typename T>
|
|
void Italiano<T>::init() {
|
|
|
|
}
|
|
|
|
template<typename T>
|
|
bool Italiano<T>::query(const T& u, const T& v) {
|
|
return TC[u] == TC[v];
|
|
}
|
|
|
|
template<typename T>
|
|
void Italiano<T>::remove(const T& u, const T& v) {
|
|
|
|
}
|
|
|
|
} // namespace algo
|
|
|
|
#endif |