# Clustering for pair-wise data

I have been looking for algorithms in Python to create clusters from pairs of data. The data structure is similar to the stackoverflow post: An algorithm to create clusters from data pairs in python, but now nodes have weights or distances on edges and each node is connected with any other nodes, like

[(id_1, id_2, 25),
(id_1, id_3, 21),
(id_1, id_4, 5),
(id_2, id_3, 1),
(id_2, id_4, 18.5),
(id_3, id_4, 22)]


I wish to obtain the result like

[(id_1, id_4), (id_2, id_3)]


id_1 and id_4 (id_2 and id_3) are close, but there exist significant distances between the clusters. Thanks!