inplemented the aformenthioned method

implemented the calculateConnectedMass method