  A classical theorem by Hartshorne states that the dual graph of any
arithmetically Cohen--Macaulay projective scheme is connected. We give a
quantitative version of Hartshorne's result, in terms of Castelnuovo--Mumford
regularity. If $X \subset \mathbb{P}^n$ is an arithmetically Gorenstein
projective scheme of regularity $r+1$, and if every irreducible component of
$X$ has regularity $\le r'$, we show that the dual graph of $X$ is
$\lfloor{\frac{r+r'-1}{r'}}\rfloor$-connected. The bound is sharp.
  We also provide a strong converse to Hartshorne's result: Every connected
graph is the dual graph of a suitable arithmetically Cohen-Macaulay projective
curve of regularity $\le 3$, whose components are all rational normal curves.
The regularity bound is smallest possible in general.
  Further consequences of our work are:
  (1) Any graph is the Hochster-Huneke graph of a complete equidimensional
local ring. (This answers a question by Sather-Wagstaff and Spiroff.)
  (2) The regularity of a curve is not larger than the sum of the regularities
of its primary components.
