## 3 Materials and Methods
### Structural and Quantitative Metric of Network Similarity  
A method differing from those described in the previous section involves measuring the similarity of pieces by examining the features of the adjacency matrix and the values of vertex and edge labels in a network representing a musical track. This way of calculating the distance between pieces accounts for both the structure (namely the graph of connections between the notes used in the piece) and the quantitative characteristics of the said connections (multiplicities: the occurrence of individual sounds and sequences between notes in the piece). The proposed method is an iterative method and extends the concept originally described in [24]. The idea is based on the observation asserting that two graph vertices are as similar to each other as their \"neighbors\" are. Thus, by iterating over all graph vertices, one can determine the similarity of entire structures. The method described in [19] introduces the measurement of three types of similarity between graphs: structural similarity (calculated as described in [24]), quantitative similarity of vertices, and quantitative similarity of edges. The structural similarity of graphs \(G_{A}\) and \(G_{B}\) characterized by transition matrices marked A and B, respectively, is calculated according to the following method. In the first place, the following matrix sequence should be calculated iteratively:  
\[Z_{k+1}=\frac{BZ_{k}A^{T}+A^{T}Z_{k}B}{\left\|BZ_{k}A^{T}+A^{T}Z_{k}B\right\| _{F}},k\geq 0, \tag{13}\]  
where matrix \(Z_{0}=\mathbf{1}\) (matrix with all elements having the value 1), \(x^{T}\)--transposition of matrix \(x\), \(\left\|x\right\|_{F}\)--Euclidean norm of matrix \(x\) (where \(n_{A}\)--number of columns of the matrix, i.e., number of vertices of the graph \(G_{A}\), \(n_{B}\)--number of rows of the matrix, i.e., the number of vertices of the \(G_{B}\) graph). The matrix element \(z_{ij}\) describes the similarity between the \(i\)-th vertex of the graph and the \(j\)-th vertex of the graph \(G_{B}\). The higher the \(z_{ij}\) value, the greater the similarity between these vertices. On this basis, we can calculate the structural similarity matrix of the form:  
\[S(G_{A},G_{B})=\left[s_{ij}\right]_{n_{B}\times n_{A}}=\lim_{k\to\infty}Z_{2k}. \tag{14}\]  
With this matrix, the problem of the optimal assignment of vertices from one matrix to another matrix can be defined to maximize the similarity of both structures. The optimal assignment problem can therefore be defined as follows:  
\[d_{S}(G_{A},G_{B})=\sum_{i=1}^{n_{B}}\sum_{j=1}^{n_{A}}s_{ij}\cdot x_{ij}\to \max, \tag{15}\]with the following constraints:  
\[ \begin{array}{l}\sum\limits_{j=1}^{n_{A}}x_{ij}\leq 1,j=\overline{1,n_{A}}\\ \sum\limits_{i=1}^{n_{B}}x_{ij}\leq 1,i=\overline{1,n_{B}}\\ \forall\limits_{i\in\{1,\ldots,n_{B}\}\}\forall\limits_{j\in\{1,\ldots,n_{A}\} }x_{ij}\in\{0,1\}.\end{array}  \tag{16}\]  
The aforementioned assignment problem can be solved by any algorithm (e.g., Hungarian algorithm allowing to solve the problem in polynomial time). The value of \(d_{S}(G_{A},G_{B})\) calculated in this way is a structural similarity of the graphs \(G_{A}\) and \(G_{B}\). The quantitative similarity of vertices of graphs \(d_{QN}(G_{A},G_{B})\) is calculated on the basis of vertex functions (and thus weight values of individual vertices). In the first place, the matrix vector should be calculated:  
\[v(G_{A},G_{B})=\langle V_{1},\ldots,V_{LF}\rangle, \tag{17}\]  
where a single matrix \(V_{k}=\left[v_{ij}(k)\right]_{n_{B}\times n_{A}},k=\overline{1,LF}\) describes the similarity of the vertices of both graphs from the perspective of the vertex function with index \(k\) defined on both graphs. The \(V_{ij}\) values are calculated as follows:  
\[v_{ij}(k)=\|f_{k}^{B}(i)-f_{k}^{A}(j)\|, \tag{18}\]  
and describe the similarity (\"distance\") of single compared vertices from the perspective of the vertex function \(f_{k}^{A},f_{k}^{B}\).