implemented approx counting variant MG algorithm