6. If $a, b \in \mathbf{R}$, then
$$
\begin{aligned}
f(a, b)= & \sqrt{2 a^{2}-8 a+10}+\sqrt{b^{2}-6 b+10}+ \\
& \sqrt{2 a^{2}-2 a b+b^{2}}
\end{aligned}
$$

the minimum value is ( ).
(A) $2 \sqrt{10}$
(B) $1+\sqrt{2}+\sqrt{5}$
(C) $2 \sqrt{5}$
(D) 4
6.C.
$$
\begin{aligned}
f(a, b)= & \sqrt{(a-3)^{2}+(a-1)^{2}}+ \\
& \sqrt{(b-3)^{2}+1}+\sqrt{(a-b)^{2}+a^{2}}
\end{aligned}
$$

represents the perimeter of the triangle in the coordinate plane $x O y$ with vertices at points $P(3,1)$, $Q(a, a)$, and $R(b, 0)$. It is easy to see that the trajectories of points $Q$ and $R$ are the lines $y=x$ and $y=0$, respectively.
As shown in Figure 5, construct the reflections of point
$P$ about the lines $y=x$ and $y=0$
to get points $P_{1}$ and $P_{2}$, respectively. It is easy to see that $P_{1}(1,3)$ and $P_{2}(3,-1)$. Connect $P_{1} P_{2}$, intersecting $y=x$ and $y=0$ at points $Q$ and $R$, respectively. Connect $P Q$ and $P R$. We will now prove that the perimeter of $\triangle P Q R$ is minimized in this configuration.

Take any points $Q^{\prime}$ and $R^{\prime}$ on the lines $y=x$ and $y=0$, respectively, and connect $P_{1} Q^{\prime}$, $P Q^{\prime}$, $Q^{\prime} R^{\prime}$, $P R^{\prime}$, and $P_{2} R^{\prime}$. Then
$$
\begin{array}{l}
P Q^{\prime}+P R^{\prime}+Q^{\prime} R^{\prime}=P_{1} Q^{\prime}+Q^{\prime} R^{\prime}+R^{\prime} P_{2} \\
\geqslant P_{1} P_{2}=P_{1} Q+Q R+R P_{2}=P Q+Q R+R P .
\end{array}
$$

Therefore, the minimum perimeter of $\triangle P Q R$ is
$$
\left|P_{1} P_{2}\right|=\sqrt{(1-3)^{2}+(3+1)^{2}}=2 \sqrt{5} \text {. }
$$