## 3 Generation of Equations
### Realizability Analysis
#### 3.2.2 Algorithm
\(\Lambda\leftarrow\) adjacency matrix of \(G\) \(B_{1},B_{2}\leftarrow\emptyset,\emptyset\) foreach\(b\in(B_{x},B_{y})\) // See Table 2  do if\(b\) is voltage-controlledthen \(B_{1}\leftarrow B_{1}\cup b\)  end if if\(b\) is current-controlledthen \(B_{2}\leftarrow B_{2}\cup b\)  end if  end for \(B_{i}\leftarrow B_{w}\) \(\Lambda(N_{0},:)\gets 0\) foreach\(b\in B_{1}\) // See constraint (C4) do \(\Lambda(:,b)\gets 0\)  end if repeat \(\Lambda^{*}\leftarrow\Lambda\) foreach\(b\in B_{2}\) // See constraint (C2) do if\(\sum\Lambda(:,b)=0\)then break:\(G\) is not realizable  end if elseif\(\sum\Lambda(:,b)=1\)then \(n\leftarrow\{n\,\text{s.t. }\,\Lambda(n,b)=1\}\) \(\Lambda(n,:\setminus b)\gets 0\)  end if foreach\(b\in B_{i}\)do if\(\sum\Lambda(:,b)=0\) // See constraint (C2) then \(B_{1}\leftarrow B_{1}\cup b\) \(B_{i}\leftarrow B_{i}\setminus b\)  end if elseif\(\sum\Lambda(:,b)=1\) // See constraint (C4) then \(n\leftarrow\{n\,\text{s.t. }\,\Lambda(n,b)=1\}\) \(\Lambda(n,:\setminus b)\gets 0\) \(B_{2}\leftarrow B_{2}\cup b\) \(B_{i}\leftarrow B_{i}\setminus b\)  end if  end foreach\(n\in N\setminus N_{0}\) // See constraint (C1) do if\(\sum\Lambda(n,:)=0\)then break:\(G\) is not realizable  end if until\(\Lambda=\Lambda^{*}\) if\(B_{i}\
eq\emptyset\)then \(b\leftarrow\) first edge in \(B_{i}\) \(B_{1}\gets B_{1}\cup b\) \(B_{i}\leftarrow B_{i}\setminus b\)  go to 10  end if return\(B_{1}\)and\(B_{2}\)
```  
**Algorithm 1**Analysis of realizability. If successfully complete, the resulting PHS structure is given by the procedure in the proof of Proposition 1  
```
Input: A graph \(G=\{N,(B_{x},B_{w},B_{y})\}\) corresponding to the interconnection of storage, dissipative, and source edges. Output: Sets of voltage-controlled edges \(B_{1}\) and current-controlled edges \(B_{2}\). \(\Lambda\leftarrow\) adjacency matrix of \(G\) \(B_{1},B_{2}\leftarrow\emptyset,\emptyset\) foreach\(b\in(B_{x},B_{y})\)



#### 3.2.3 Example

As an example, the realizability analysis for the system in Figure 2 with the choice of inputs/outputs in Table 1 is as follows. In step 1, the realizability matrix \(\Lambda\) is initialized with the adjacency matrix \(\mathsf{A}\), which is built by taking the absolute value of incidence matrix \([\mathsf{A}]_{n,b}=\mathrm{abs}\big{(}[\Gamma]_{n,b}\big{)}\):

\[\Lambda=\mathsf{A}= \begin{pmatrix}\mathbb{C}1&\mathrm{R}1&\mathrm{Q}\mathrm{I }\mathrm{b}\mathrm{c}&\mathbb{Q}\mathrm{I}\mathrm{b}\mathrm{e}&\mathrm{V} \mathrm{c}\mathrm{c}\mathrm{c}\mathrm{i}\mathrm{N}&\mathrm{OUT}&\mathrm{GRD} \\ \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&\vdots&\vdots&\vdots&1&\vdots\\ \vdots&1&\vdots&\vdots&1&\vdots&\vdots&1\\ \vdots&\vdots&\vdots&1&\vdots&\vdots&1\\ \end{pmatrix} \begin{array}{c}N_{0}\\ N_{1}\\ N_{2}\\ N_{3}\\ N_{4}\\ N_{5}\end{pmatrix}\;. \tag{14}\]

In steps 3-7, the set of edges \(\mathsf{B}=\{C_{1},R_{1},Q_{1,bc},Q_{1,be},IN,Vcc,OUT,GRD\}\) is split as \(\mathsf{B}=\{\mathsf{B}_{1},\mathsf{B}_{1},\mathsf{B}_{2}\}\) according to the definition of components with voltage-controlled edges \(\mathsf{B}_{1}=\{Q_{1,bc},Q_{1,be},OUT\}\), current-controlled edges \(\mathsf{B}_{2}=\{C_{1},Vcc,IN,GRD\}\), and indeterminate edge \(\mathsf{B}_{1}=\{R_{1}\}\):

\[\Lambda= \begin{pmatrix}\mathbb{Q}1,\mathrm{b}\mathrm{c}\mathrm{Q}\mathrm{I}, \mathrm{b}\mathrm{e}\mathrm{OUT}&\mathrm{R}1&\mathbb{C}1&\mathrm{V}\mathrm{c} \mathrm{c}\mathrm{i}\mathrm{N}&\mathrm{GRD}\\ \vdots&\vdots&1&\vdots&\vdots&1&1&1\\ \hline\vdots&\vdots&\vdots&\vdots&1&\vdots&1&\vdots&N_{1}\\ 1&1&\vdots&\vdots&1&\vdots&\vdots&\vdots&N_{2}\\ 1&\vdots&1&1&\vdots&\vdots&\vdots&\vdots&N_{3}\\ \vdots&\vdots&\vdots&1&\vdots&1&\vdots&\vdots&N_{4}\\ \vdots&1&\vdots&\vdots&\vdots&\vdots&\vdots&1\\ \end{pmatrix} \;. \tag{15}\]

The realizability matrix after step 11 in Algorithm 1 is

\[\Lambda=