add unit test for union find algorithm