Islands function

Find islands from distance matrix