  We investigate the extent to which the exchange relation holds in finite
groups $G$. We define a new equivalence relation $\equiv_{\mathrm{m}}$, where
two elements are equivalent if each can be substituted for the other in any
generating set for $G$. We then refine this to a new sequence
$\equiv_{\mathrm{m}}^{(r)}$ of equivalence relations by saying that $x
\equiv_{\mathrm{m}}^{(r)}y$ if each can be substituted for the other in any
$r$-element generating set. The relations $\equiv_{\mathrm{m}}^{(r)}$ become
finer as $r$ increases, and we define a new group invariant $\psi(G)$ to be the
value of $r$ at which they stabilise to $\equiv_{\mathrm{m}}$.
  Remarkably, we are able to prove that if $G$ is soluble then $\psi(G) \in
\{d(G), d(G) +1\}$, where $d(G)$ is the minimum number of generators of $G$,
and to classify the finite soluble groups $G$ for which $\psi(G) = d(G)$. For
insoluble $G$, we show that $d(G) \leq \psi(G) \leq d(G) + 5$. However, we know
of no examples of groups $G$ for which $\psi(G) > d(G) + 1$.
  As an application, we look at the generating graph of $G$, whose vertices are
the elements of $G$, the edges being the $2$-element generating sets. Our
relation $\equiv_{\mathrm{m}}^{(2)}$ enables us to calculate
$\mathrm{Aut}(\Gamma(G))$ for all soluble groups $G$ of nonzero spread, and
give detailed structural information about $\mathrm{Aut}(\Gamma(G))$ in the
insoluble case.
