Node analysis with voltage source in matrix form
The "third case" your professor mentioned deals with the issue that you don't always want to replace an existing KCL equation with the voltage source equation. This is especially true in circuit simulators, where an extra equation doesn't mean much. In that case, you want to add the voltage source equation, while keeping all the other KCL equations, but then you end up with \$n+1\$ equations for \$n\$ unknowns.

The current through the voltage source can be added as an extra unknown to fix this situation. Applying this method is part of so-called Modified Nodal Analysis. The added current will become part of the KCL equations.

So whatever circuit you have, you can "insert" a voltage source in the matrix by writing:

$$\left(\begin{matrix}
G_{11} &amp; \dots &amp; G_{1A} &amp; \dots &amp; G_{1B} &amp; \dots &amp; G_{1n} &amp; 0 \\
\vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; \vdots \\
G_{A1} &amp; \dots &amp; G_{AA} &amp; \dots &amp; G_{AB} &amp; \dots &amp; G_{An} &amp; 1 \\
\vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; \vdots \\
G_{B1} &amp; \dots &amp; G_{BA} &amp; \dots &amp; G_{BB} &amp; \dots &amp; G_{Bn} &amp; -1 \\
\vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; &amp; \vdots &amp; \vdots \\
G_{n1} &amp; \dots &amp; G_{nA} &amp; \dots &amp; G_{nB} &amp; \dots &amp; G_{nn} &amp; 0 \\
0 &amp; \dots &amp; 1 &amp; \dots &amp; -1 &amp; \dots &amp; 0 &amp; 0
\end{matrix}\right)\left(
\begin{matrix}
V_1 \\
\vdots \\
V_A \\
\vdots \\
V_B \\
\vdots \\
V_n \\
I_V
\end{matrix}\right) = \left(\begin{matrix}
I_1 \\
\vdots \\
I_A \\
\vdots \\
I_B \\
\vdots \\
I_n \\
V
\end{matrix}\right)$$

where the voltage source is connected between nodes \$A\$ and \$B\$, and \$I_V\$ is the current flowing through the voltage source. If either A or B are grounded, then you can remove row and column A or B respectively.