implement label-propagation algorithm