Algebraic characterization of geometric 4-manifolds