Partitioning a graph using FM-algorithm