Computing Persistent Homology by Spanning Trees and Critical Simplices