Additional operations disjoint-set (disjoint set) , its function is to achieve undo the last operation.
Realize ideas
Initialize an empty stack, each time two root set of operations and the value stack; if performed operation, the stack only needs to be can operate. Nopath compressiontime, this strategy is valid; if disjoint-set (disjoint set) to achieve apath compression, such that the operation difficult, since thepath compressora great probability originally belonging to the elements under a root connected to the other root, if performed at this time operation, it is difficult to recover.