问题 I have a set of pairs. Each pair is represented as [i,1:2] . That is, the ith pair are the numbers in the first and second column in the ith row. I need to sort these pairs into distinct groups, s.t. there is no element in any pair in the jth group that is in any group not j . For example: EXAMPLE 1: DATA > col1 <- c(3, 4, 6, 7, 10, 8) > col2 <- c(6, 7, 3, 4, 3, 1) > > dat <- cbind(col1, col2) > rownames(dat) <- 1:nrow(dat) > > dat col1 col2 1 3 6 2 4 7 3 6 3 4 7 4 5 10 3 6 8 1 For all pairs,