Algorithm for Graph merge and recompute
I suggest you start by reading about standard clustering algorithms and methods for clustering.  You could start with Wikipedia: cluster analysis and hierarchical clustering, then move on to textbooks or online resources.  Especially, check out hierarchical clustering to see if any of its methods might do what you want.

It sounds like you're not quite sure what you want.  So, if you learn more about standard clustering methods, you might be in a better position to formulate a narrower, more focused question -- or if you're lucky, maybe you'll find a solution you're happy with.