Add utility for computing graph weight.