So we're going to what we're going to do is maintain a set for each of the connected components in the spanning tree, that we built up so far and so if the new edge connects vertices that are in the same set, then that means it would create a cycle. 