Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "edge_list.hpp"
- #include <atomic>
- class DynamicConnectivity {
- public:
- using Node = long;
- DynamicConnectivity();
- explicit DynamicConnectivity(long num_nodes);
- // should contain #pragma omp parallel for
- void addEdges(const EdgeList &edges);
- bool connected(Node a, Node b) const;
- // Must return -1 for roots.
- Node parentOf(Node n) const;
- void printUF();
- private:
- std::atomic<Node> *union_find;
- Node find_representative(Node a) const;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement