fixed bug in spanning tree calculation and finished main function.