  Fr\"oberg's classical theorem about edge ideals with $2$-linear resolution
can be regarded as a classification of graphs whose edge ideals have linearity
defect zero. Extending his theorem, we classify all graphs whose edge ideals
have linearity defect at most $1$. Our characterization is independent of the
characteristic of the base field: the graphs in question are exactly weakly
chordal graphs with induced matching number at most $2$. The proof uses the
theory of Betti splittings of monomial ideals due to Francisco, H\`a, and Van
Tuyl and the structure of weakly chordal graphs. Along the way, we compute the
linearity defect of edge ideals of cycles and weakly chordal graphs. We are
also able to recover and generalize previous results due to
Dochtermann-Engstr\"om, Kimura, and Woodroofe on the projective dimension and
Castelnuovo-Mumford regularity of edge ideals.
