An iteration method for computing the total number of spanning trees and its applications in graph theory