This could be effectively solved using the igraph
library:
common_ids <- clusters(graph_from_data_frame(df, directed = FALSE))$membership
split(1:nrow(df), common_ids[match(df$c1, names(common_ids))])
$`1`
[1] 1 3 4
$`2`
[1] 2 5
If also members of the groups are of interest:
split(names(common_ids), common_ids)
$`1`
[1] "1" "2" "7" "8"
$`2`
[1] "3" "5" "10"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…