defining the clustering and message passing framework