Computes weight of minimum spanning tree of two different types of graphs.