1. A method clustering nodes in a network, comprising the steps of: determining, in each node, a cluster head capability (CHC); broadcasting, directly or indirectly by each node, the CHC until all nodes have received the CHCs; maintaining, in each node, a set (NB) that includes neighboring nodes j of the node i, wherein each entry in the set NB(i) has a format (ID, D, CHC), where ID represents an identifier of the neighboring node j, D represents a distance between the node i and the neighboring node j, and the CHC represents the cluster head capability of node j and wherein the CHC is CHCi=C(i)/Cmax*Ei*ERi, where C(i) is a capability classification of node i, Cmax is a maximal classification index, E(i) is a percentage of remaining energy of node i, and ER(i) is an expected reliability of node i when the node i is the cluster head; nominating, in each node, one or more candidate cluster heads based on the CHCs; and selecting, in each node, at least one cluster head from the one or more candidate cluster head nodes, wherein the at least one cluster head has a maximal CHCs for the one or more candidate cluster head nodes.