text: To check if there are cycles . If yes , then they are not convertible . Else , they are convertible .
code: foreach ( KeyValuePair < int , int > it in mp ) { if ( it . Key == it . Value ) continue ; else { if ( find ( it . Key ) == find ( it . Value ) ) return false ; else join ( it . Key , it . Value ) ; } } return true ; }