## 2 Background
### Graph and Network Representation of Music  
There are several ways to map a piece to its graph representation. The individual issues that should be considered and the available possibilities of the graph and network representation of notes have been described in more detail in [17], hence only those aspects that are used for the purpose of graph similarity study are mentioned below. The first aspect of the graph representation of a piece is the way in which the notes are mapped to the vertices of the graph. Formally speaking, the issue concerns defining the function:  
\[f:N\to V. \tag{5}\]  
The following function is adopted in this paper (similar to that proposed in [20] but limited to keys from a piano keyboard and distinguishing only note names instead of names with octaves):  
\[f(freq_{i})=\left\{ \begin{matrix}12&freq_{i}\leq 0\\ \left[12\cdot\log_{2}\!\left(\frac{freq_{i}}{400\,\mathrm{Hz}}\right)+58 \right]mod\,12&freq_{i}>0\end{matrix} \right.. \tag{6}\]  
Such a definition means that all notes are transformed to vertices corresponding to their names (e.g., 0--note C, 1--note C#, 2--note D, etc. ), while all rests are represented by a separate vertex of the graph. There are 12 semitones in a single octave, hence the resulting graph has a maximum of 13 vertices. Information about the octave number comprising the note in the piece is not stored--when notes have the same name but originate from different octaves (namely the frequency of one of them is \(2^{i}\) times the frequency of the other), they are represented by the same vertex. In the described method, the graph always contains all possible vertices (even when some of them are not present in the piece), and this is due to the need to generate an adjacency matrix with a size of 13 \(\times\) 13 vertices. Vertices representing notes that are not present in the piece are called isolated vertices--their addition is a technical operation and is responsible for the \"standardization\" of the resulting matrix (whereas the algorithms for generating the arrangement take into account only vertices with a positive degree). The next aspect of note representation consists in the mapping of the relationship between notes in the form of directed or undirected edges. For this purpose, the so-called note precedence relationship has been defined. This relationship takes the following form as described in [17]:  
\[R=\{\langle N_{1},\ N_{2}\rangle\in N\times N:t_{1}\leq t_{2}\}. \tag{7}\]  
The relationship defined in this way is a relationship that introduces a linear order on the set of notes of a musical piece, and this was described in more detail in [17]. Particularly important are pairs of notes that occur immediately after each other, namely those constituting pairs of an immediate precedence relationship:  
\[I=\{\langle N_{1},\ N_{2}\rangle\in R:t_{2}=t_{1}+m_{1}\}. \tag{8}\]  
Pairs of this relationship are used to build the graph of a piece of music. In the method described in this article, directed edges (directing from the predecessor to the successor of the ordered pair) are added between all pairs of notes belonging to this relationship. This renders it possible to model the relationship between the notes in the piece, \"flow\" and \"movement\" between them. The third aspect of note representation characteristic for the network is the weights (labels) of vertices and edges. Therefore, we may define the following vertex weight function reflecting the cardinality of occurrence of the corresponding note in the piece:  
\[\mu(v)=|\{n_{i}\in N:f(n_{i})=v\}|,v\in V. \tag{9}\]  
In other words, if note C occurred five times in the original piece (regardless of the octave and the length of the notes in each of its occurrences), then the vertex with index 0 corresponding to this note shall have a label equal to 5.