Checking if vertices in different components when performing union, added docs