Clustering of Sparse and Approximately Sparse Graphs by Semidefinite Programming