simulate this circuit – Schematic created using CircuitLab
Can you please check if my reasoning is correct?
The sum of currents leaving node k is: $$ I_k = \sum_{i = 0}^{n} I_{ki} = \sum_{i = 0}^{n} G_{ki}(V_k - V_i)$$ Assuming the system is linear: $$ I_k = \sum_{i = 0 (i \neq k)}^{ n} G_{ki} V_k - \sum_{i = 1 ( i \neq k)}^{n} G_{ki}V_i = G_{kk}V_k - \sum_{i = 1 ( i \neq k)}^{n} G_{ki} V_i $$ where: $$G_{kk} = \sum_{i = 0 (i \neq k)}^{n} G_{ki} $$ then we have: $$I_n = -G_{n1}V_1 - G_{n2} ... + G_{nn}V_n $$ which in matrix form gives: $$\begin{bmatrix}I_1 \\ I_2 \\. \\ . \\ . \\ I_n\end{bmatrix} = \begin{bmatrix} G_{11}& -G_{12}& -G_{13} ... &-G_{1n} \\ -G_{21}& G_{22}& -G_{23} ... &-G_{2n} \\ .&.&.&. \\ .&.&.&. \\ .&.&.&. \\ -G_{n1}& -G_{n2}& -G_{n3} ... &G_{nn} \end{bmatrix}\begin{bmatrix}V_1 \\ V_2 \\. \\ . \\ . \\ V_n\end{bmatrix}$$ In case there is an ideal voltage source connected between a node and the reference, then the voltage of that node is equal to the EMF of that voltage source. So in matrix form we have(if for example node 1 was connected to an ideal voltage source): $$\begin{bmatrix}E_1 \\ I_2 \\. \\ . \\ . \\ I_n\end{bmatrix} = \begin{bmatrix} 1& 0& 0 ... &0 \\ -G_{21}& G_{22}& -G_{23} ... &-G_{2n} \\ .&.&.&. \\ .&.&.&. \\ .&.&.&. \\ -G_{n1}& -G_{n2}& -G_{n3} ... &G_{nn} \end{bmatrix}\begin{bmatrix}V_1 \\ V_2 \\. \\ . \\ . \\ V_n\end{bmatrix}$$ However, if we have an ideal voltage source between two nodes (neither of them being the reference), for example between nodes 1 and 3 we have E, then we have: $$\begin{bmatrix}I_1 \\ I_2 \\E \\ . \\ . \\ I_n\end{bmatrix} = \begin{bmatrix} G_{11}& -G_{12}& -G_{13} ... &-G_{1n} \\ -G_{21}& G_{22}& -G_{23} ... &-G_{2n} \\ -1&0&1&0 \\ .&.&.&. \\ .&.&.&. \\ -G_{n1}& -G_{n2}& -G_{n3} ... &G_{nn} \end{bmatrix}\begin{bmatrix}V_1 \\ V_2 \\. \\ . \\ . \\ V_n\end{bmatrix}$$ My professor claimed that the third case had a more elegant solution which included adding an imaginary node and a new current, but I cannot understand what he meant, any insight?