algorithm to get the class edges