66#ifndef __ADS_RollbackUnionFind
67 #define __ADS_RollbackUnionFind
107 [[nodiscard]]
int n(
void )
const {
return(
int( f_p.size() ) ); }
110 [[nodiscard]]
int count(
void )
const {
return( f_count ); }
124 [[nodiscard]]
int find(
int x )
const;
154 [[nodiscard]]
bool same(
int x ,
int y )
const {
160 [[nodiscard]]
int size(
int x )
const {
return( f_size[
find( x ) ] ); }
164 return(
int( f_stack.size() ) );
204 [[nodiscard]]
bool forest(
void )
const;
206 std::vector< int > f_p;
207 std::vector< int > f_rank;
208 std::vector< int > f_size;
209 std::vector< Record > f_stack;
273[[nodiscard]]
inline std::vector< int >
284#include "ADS/mfset/impl/RollbackUnionFind.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
int find(int x) const
the representative of the component of , in
int size(int x) const
the number of elements of the component of
Definition RollbackUnionFind.h:160
RollbackUnionFind(int n=0)
the components , no merge done
void undo(int k=1)
undoes the last merges
bool merge(int x, int y)
joins the components of and , the root of lower rank under the other, and records it; true if they w...
bool same(int x, int y) const
whether and are in the same component
Definition RollbackUnionFind.h:154
int checkpoint(void) const
the merges done and not undone, the time to roll back to
Definition RollbackUnionFind.h:163
int n(void) const
the number of elements
Definition RollbackUnionFind.h:107
void reset(int n)
back to the components, no merge done
int count(void) const
the number of components
Definition RollbackUnionFind.h:110
void rollback(int t)
undoes the merges back to the checkpoint , i.e., undo( checkpoint() - t )
std::vector< int > offlineConnectivity(int n, const std::vector< ConnectivityOp > &ops)
the answers to the questions of ops on nodes, in their order: 1 or 0 for CONNECTED,...
an operation on a graph whose edges come and go
Definition RollbackUnionFind.h:220
int u
the first node
Definition RollbackUnionFind.h:229
Kind
the kinds of operation
Definition RollbackUnionFind.h:222
@ COMPONENTS
how many components there are
Definition RollbackUnionFind.h:226
@ CONNECTED
whether and are connected
Definition RollbackUnionFind.h:225
@ INSERT
the insertion of the edge
Definition RollbackUnionFind.h:223
@ DELETE
the deletion of the edge
Definition RollbackUnionFind.h:224
Kind kind
the kind
Definition RollbackUnionFind.h:228
int v
the second node
Definition RollbackUnionFind.h:230