  A path in an edge-colored graph, where adjacent edges may be colored the
same, is a rainbow path if no two edges of it are colored the same. A
nontrivial connected graph $G$ is rainbow connected if there is a rainbow path
connecting any two vertices, and the rainbow connection number of $G$, denoted
by $rc(G)$, is the minimum number of colors that are needed in order to make
$G$ rainbow connected. Chartrand et al. obtained that $G$ is a tree if and only
if $rc(G)=m$, and it is easy to see that $G$ is not a tree if and only if
$rc(G)\leq m-2$, where $m$ is the number of edge of $G$. So there is an
interesting problem: Characterize the graphs $G$ with $rc(G)=m-2$. In this
paper, we settle down this problem. Furthermore, we also characterize the
graphs $G$ with $rc(G)=m-3$.
