Community structure from spectral properties in complex networks