A characterization of singular graphs