A Unifying Framework for Spectrum-Preserving Graph Sparsification and Coarsening