union find

a simple usage of union find, to check if there is a cycle in a graph?