Solution (source code)

= Solution

The first diagram is $D_4$, with central node $\alpha_2$. Its Cartan matrix is
$$
\begin{pmatrix}
2&-1&0&0\\-1&2&-1&-1\\0&-1&2&0\\0&-1&0&2
\end{pmatrix}.
$$