a partitioning algorithm for non-directional, weighted graph