## 3 Generation of Equations
### Graph Encoding
#### 3.1.3. Kirchhoff's Laws on Graphs  
We assign to each branch \(b\) both a voltage \(v_{b}\) and a current \(i_{b}\) in _receiver convention_, the direction of the branch indicating the direction of the current. Note that the power supplied to the system on port \(p\) is the power _emitted_ by the port branch \(S_{p}=u_{p}\cdot y_{p}=-v_{p}\cdot i_{p}\). For a circuit made of \(n_{N}+1\) nodes and \(n_{B}=n_{S}+n_{D}+n_{P}\) branches, we define: the set of electrostatic potentials on the nodes \(\mathbf{e}=(e_{1}\cdots e_{n_{N}})^{\intercal}\), the set of voltages \(\mathbf{v}=(v_{1}\cdots v_{n_{B}})^{\intercal}\), and the set of currents \(\mathbf{i}=(i_{1}\cdots i_{n_{B}})^{\intercal}\). The orientation of an entire graph is encoded in its _incidence matrix_\(\Gamma\in\mathbb{R}^{(n_{N}+1)\times n_{B}}\), defined below [27] (SS9).  
\begin{table}
\begin{tabular}{l l l l l} \hline \hline
**Line** & **Label** & **Node List** & **Type** & **Parameters** \\ \hline \(\ell_{1}\) & C1 & \(N_{1},N_{2}\) & CapaLin & \(20e^{-9}\) \\ \(\ell_{2}\) & \(R1\) & \(N_{3},N_{4}\) & Resistor & \(1.5e^{3}\) \\ \(\ell_{3}\) & Q1 & \(N_{2},N_{3},N_{5}\) & NPN\_ Type1 & _List of parameters_ \\ \(\ell_{4}\) & Vcc & \(N_{4}\) & Voltage & 9 \\ \(\ell_{5}\) & IN & \(N_{1}\) & Voltage & \(\sim\) \\ \(\ell_{6}\) & OUT & \(N_{3}\) & Current & 0 \\ \(\ell_{7}\) & GRD & \(N_{5}\) & Voltage & 0 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Example of a netlist corresponding to the circuit in Figure 2. The grey part corresponds to the components, and the other elements correspond to the external ports, or sources (as in figure 2).  
\[[\Gamma]_{n,b}=\left\{\begin{array}{rl}-1&\text{if branch $b$ is outgoing node $n$,}\\ 1&\text{if branch $b$ is ingoing node $n$,}\\ 0&\text{otherwise.}\end{array}\right. \tag{6}\]  
As an example, the incidence matrix for the circuit described in Table 1 is given equation below (0 are replaced by dots). Notice the grey columns correspond to the components, and the other columns correspond to the external ports, or sources (as in Table 1 and Figure 2).  
\[\Gamma=\left(\begin{array}{ccccccccc}\bar{C}1&\bar{R}1&\bar{Q} \bar{I},\text{bc}&\bar{Q}\bar{I},\text{be}&\text{Vcc}&\text{IN}&\text{OUT}& \text{GRD}\\ \vdots&\vdots&\vdots&\vdots&\vdots&1&1&1&1\\ 1&\vdots&\vdots&\vdots&\vdots&-1&\vdots&\vdots\\ -1&\vdots&1&1&\vdots&\vdots&\vdots&\vdots\\ \vdots&1&-1&\vdots&\vdots&\vdots&-1&\vdots\\ \vdots&-1&\vdots&\vdots&-1&\vdots&\vdots&\vdots\\ \vdots&\vdots&\vdots&-1&\vdots&\vdots&\vdots&-1\\ \end{array}\right)\begin{array}{c}N_{0}\\ N_{1}\\ N_{2}\\ N_{3}\\ N_{5}\end{array}. \tag{7}\]  
Since the reference potential \(e_{0}\) does not influence the voltages nor the currents, it is not taken into account in the [PERSON]'s laws, and we define the reduced incidence matrix \(\widehat{\Gamma}\in\mathbb{R}^{n_{N}\times n_{B}}\) obtained by deleting the row corresponding to the datum \(\mathsf{N}_{0}\) in \(\Gamma\). This leads to the following matrix formulation of Kirchhoff's Voltage Law (KVL) and Kirchhoff's Current Law (KCL) [27] (SS10), from which the structure (5) is derived.  
\[\left\{\begin{array}{rcl}\widehat{\Gamma}^{\intercal}\cdot\mathbf{e}&=& \mathbf{v},&\text{(KVL)}\\ \widehat{\Gamma}\cdot\mathbf{i}&=&0.&\text{(KCL)}\end{array}\right. \tag{8}\]