Tonal harmony and the topology of dynamical score networks

I introduce the concept of dynamical score networks for the representation and analysis of tonal compositions: a score is interpreted as a dynamical network where every chord is a node and each progression links successive chords. This network can be viewed as a time series of a non-stationary signal, and as such, it can be partitioned for the automatic identiﬁcation of tonal regions using time series analysis and change point detection without relying on comparisons with pre-determined reference sets or extensive corpora. I demonstrate that the essential features of tonal harmony, centricity, referentiality, directedness and hierarchy, emerge naturally from the network topology and its scale-free properties. Finally, solving for the minimal length path through a route optimization algorithm on these graphs provides an abstraction of harmonic sequences that can be generalized for the conception of generative models of tonal compositional design.


Introduction
The article "Topology of Networks in Generalized Musical Spaces," recently published in the Leonardo Music Journal (Buongiorno Nardelli 2020) introduces the concept of harmony as a network representation of the musical structures built out of all possible combinatorial pitch class sets in any arbitrary temperament.Inspired by a long tradition of network representations of musical structures such as the circle of fifths (Heinichen 1969), the Tonnetz (Euler 1739), and recent works on the spiral array model of pitch space (Chew 2014), the geometry of musical chords (Tymoczko 2006) and generalized voice-leading spaces (Callender, Quinn, and Tymoczko 2008;Tymoczko 2012), I interpret the harmonic structure of a composition as a large-scale complex network whose topological properties uncover its underlying organizational principles and demonstrates how classifications or rule-based frameworks (such as common-practice harmony, for instance) can be interpreted as emerging phenomena in a complex network system.Since the conclusions of that study serve as foundations for the present paper, I review some of its principal results.
Network analysis methods exploit the use of graphs or networks as convenient tools for modelling relations in large data sets.If the elements of a data set are thought of as "nodes," then the emergence of pairwise relations between them, "edges," yields a network representation of the underlying set.Similar to social networks, biological networks and other well-known realworld complex networks, entire datasets of musical structures can be treated as networks, where each individual musical entity (pitch class set (pcset), chord, rhythmic progression, etc.) is represented by a node, and a pair of nodes is connected by a link if the respective two objects exhibit a certain level of similarity according to a specified quantitative metric.Pairwise similarity relations between nodes are thus defined through the introduction of a measure of "distance" in the network: a "metric" (Albert and Barabási 2002).As in more well-known social or biological networks, individual nodes are connected if they share a certain property or characteristic (i.e. in a social network people are connected according to their acquaintances, collaborations, common interests, etc.).Clearly, different properties of interest can determine whether a pair of nodes is connected; therefore, different networks connecting the same set of nodes are possible.
In this paper I construct networks where nodes are the individual chords that can be extracted from the score, and edges are built between successive chords in the progression: nodes are connected if they appear as neighbours in the sequence.Naturally, nodes are visited numerous times, and the score evolution implies a directionality of the links.The networks are thus "directed," and each edge will have a weight (strength) proportional to the times the link is visited.
Given such a network, we can perform many statistical operations that shed light on the internal structure of the data.In this work I will consider two of such measures, degree centrality and modularity class (Barabasi and Posfai 2016).The degree of a node is measured by the number of edges that depart from it.It is a local measure of the relative "importance" of a node in the network.Modularity is a measure of the strength of division of a network into communities: high modularity (above 0.6 on a scale from 0 to 1) corresponds to networks that have a clearly visible community structure (Zinoviev 2018).Isolating communities through modularity measures provides a way to operate within regions of higher similarity, and thus, as I will demonstrate in this paper, of closer harmonic content.Of particular interest in the context of this paper is the observation that tonal score networks exhibit scale-free properties, that is, their distribution of node degrees follows some form of power law, at least asymptotically.Scale-freeness is often associated with networks with few nodes with many connections (hubs) while the remainder exhibits relatively few connections (edges) (Barabasi and Posfai 2016).Section 6 discusses in more detail the preferential attachment algorithm of Barabasi and Albert for the generation of scale-free networks (Barabasi and Albert 1999).
As summarized very effectively by Moss et al. (2019), tonal harmony compositions share four essential features: centricity, referentiality, directedness, and hierarchy.I argue here that all of these properties are completely captured by the network representation outlined above: centricity, the observation that tonal harmony is governed by a few central chords (Neuwirth et al. 2018), is captured by the degree distribution and the scale-free character of the score network, as discussed by (Buongiorno Nardelli 2020) and in this article.Chords do not occur in random order, but they are introduced following syntactical rules: referentiality introduces the idea that chords occur within a hierarchical structure at both global (among tonal regions) and local level (between individual chords) (Schoenberg 1969;Lerdahl and Jackendoff 1983;Rorhmeier 2011;Tymoczko 2003); directedness, is the preference for asymmetric chord progressions in tonal music (Hedges and Rohrmeier 2011): it has direct implications in the formation of listening expectations and the directionality of chord progressions towards a build-up on expectation and release; finally, hierarchy involves the construction of hierarchical relationships at every level of the composition, from the locality of chords to the global organization of tonal regions and keys within a single piece (Schenker 1954;Lerdahl and Jackendoff 1983).
We now illustrate these key concepts and how they relate to the network representation of a given score with an example.In Figure 1, we show the score network of J.S. Bach's chorale from the Cantata "An Wasserfluessen Babylon," BWV 267.The edges here are directional, to Figure 1.Score network of J.S. Bach's chorale from the Cantata "An Wasserfluessen Babylon," BWV 267.Nodes' radius is proportional to their degree and colours individuate different modularity classes.Edges are directional (arrows) to reflect the harmonic progression of the composition, and their thickness is proportional to the number of times that edge is visited.In this figure and in the following, network graphics and basic statistics are obtained using the Gephi app at www.gephi.org.
indicate the pcsets progression in the piece (from now on, the term "pcset" and "chord" will be used interchangeably to denote any vertical arrangement of pitch classes).A simple statistical analysis shows that the network has an average degree of 1.9 per node, and a modularity index of 0.5: the distribution of edges is relatively sparse, and many nodes are visited numerous times.One of the main results of such analysis is that the classification of nodes based on the modularity index clearly individuates tonal regions visited in the short piece (colour-coded in Figure 1): G Major/C Major (blue), A minor (magenta), D minor (purple).Although we will come back for a more thorough analysis of the chorale in Section 5, we can still make some important observations: first, a statistical measure of modularity (a well-defined mathematical measure), individuates broadly the tonal regions of the piece without any a priori knowledge of the harmonic structure (referentiality and hierarchy); second, that the distribution of nodes' degrees gives us a way of identifying the individual tonal regions: the most important functional chords (tonic and dominant) are the ones that are visited more often (centricity); finally, the network is clearly directional: some progressions are more frequent than others, or directedness, a manifestation of the asymmetry of chord progressions in tonal harmony (Moss et al. 2019).
In the discussion above, we are taking a static perspective on the score network: we build its graph representation by collecting all the nodes (chords) and progressions (directional edges) from the whole piece.However, this is a procedure that ignores completely the fact that a piece of music is a temporal system, that is, each occurrence of any pcset is aligned according to a time scale, from the first to the last chord.This observation leads to the interpretation of the temporal network as a time series allowing the use of well-established techniques for time series analysis and change point detection in the evaluation of the harmonic content of the composition.In particular, I will demonstrate how we can automatically identify key regions in tonal compositions without relying on comparisons with pre-determined perceptual reference sets, such as in the Krumhansl-Schmuckler key-finding algorithm (Temperley 1999), or machine-learning methods applied to comprehensive corpora (Micchi, Gotham, and Giraud 2020).

Methodology and data preparation
This section will illustrate all the ideas and models using a particular example: the score of the string quartet in E Major, Op. 127 n. 12 by L. van Beethoven.However, all algorithms and procedure developed here are generally applicable to any composition, even beyond those written in the tonal harmony idiom.I use two principal software libraries for computational music analysis, both written in the Python language: MUSICNTWRK (at www.musicntwrk.com)and music21 (at web.mit.edu/music21).MUSICNTWRK is an open-source python library for pitch class set and rhythmic sequences classification and manipulation, the generation of networks in generalized music and sound spaces, deep learning algorithms for timbre recognition, and the sonification of arbitrary data (Buongiorno Nardelli 2019).music21, developed at MIT (Cuthbert and Ariza 2010), is an object-oriented toolkit for analysing, searching, and transforming music in symbolic (score-based) forms of great versatility, whose modularity allows a seamless integration with MUSICNTWRK and other applications.All the results are compiled in a set of IPython Jupyter notebooks available from the author upon request.
Scores are read in musicxml format by the readSCORE function of MUSCNTWRK, where their harmonic content (and other relevant information, like in which bar the chord is found) is extracted using the music21 parser and converter (using the "chordify" method).With this we obtain easily the full sequence of pcsets, chord by chord, where each change to a new pitch results in a new chord.Upon "chordification," each pcset is reduced to its normal form.While such "quantization" of pcsets is quite adequate for the analysis of pieces with a homophonic texture where each vertical pcset plays some functional values (for instance in the corpus of J.S. Bach's chorales), for compositions where there is more contrapuntal development, the number of individual pcsets in the sequence can become very large, without providing necessarily more detailed information, since many such chords are only modifications via passing notes or vagrant harmonies.To make the analysis more manageable without losing any functional value, when appropriate I use a "filtering" algorithm based on the cumulative measure of how many times an individual pcset appears in the sequence (a more detailed discussion of the filtering procedure can be found in Section S1 in the Supplementary Online Material (SOM)).Figure 2 shows the time-series of the first movement of the Beethoven string quartet Op. 127 after the filtering.
From the plot in Figure 2 we can draw already some observations: a. Repetition: from the beginning of the composition, we observe a number of pcsets that are encountered with higher frequency b.Clustering: there are clear temporal clusters that appear during the time evolution c.Incrementality: new pcsets are continuously added throughout the duration of the piece: new harmonic material is continuously added until the end.
These observations have a musical counterpart that will become more apparent in the next section.For now, it is sufficient to say that the frequency of occurrence of pcsets is probably a manifestation of the concept of centrality, while clustering and incrementality are likely a manifestation of the referentiality and hierarchy properties discussed above.

The static score network
We can now build the score network as outlined in the Introduction: each of the unique pcsets are the nodes of a directional network, displayed in Figure 3. Nodes are labelled with the chord name; their radii are proportional to their degree (the number of connections each node has with the rest of the network) and are colour-coded according to their modularity class.Similar to the case of Bach's chorale discussed above, also here belonging to a particular modularity class implies an underlining tonal region: we can broadly identify the magenta with the principal tonality, E major (the E major triad is central in this partition), C minor (yellow) and G minor (blue).However, a better understanding of the tonal dynamics of the piece can be gleaned only from the analysis of the changing topology during the time evolution of the network (see next Section).
Here, I extend our discussion with a quantitative analysis of the network topology and its scalefree properties.Figure 4 shows, in a loglog scale, the degree distribution of the score network.As it is clear from the figure, there are few nodes with very high degree (centrality) that act as hubs, while the vast majority of them follows a power-law distribution, a characteristic of scalefree networks (examples of power law distributions that might be familiar to the readers include the Pareto (80-20) rule and the Zipf distributions).For a thorough discussion of the properties of scale-free networks and the implications for practical applications see Barabasi and Posfai (2016); here I summarize some of the most important consequences of scale-freedom.In the context of tonal harmony, the most important consequence of the appearance of hub chords in a score network is that their presence decreases the number of steps needed to go from one node to another: distances in a scale-free network are smaller than the distances observed in networks where the node degrees follow a random (flat) distribution.Hub chords act as "pivots" within progressions and between them, allowing for seamless transitions between tonal regions (they satisfy both the referentiality and hierarchy properties).After all, this is a manifestation of the elementary fact well known to any harmony student: the same chord coexists in different keys and with different functional properties, I in C major is also V in F major and so on.Our results align with the conclusions of a previous study of the statistical characteristics of tonal harmony in Beethoven string quartets, where the power law behaviour was inferred from the chord lexicon analysed as an n-gram model as in natural language processing (Moss et al. 2019).However,

The dynamical score networks
The analysis conducted so far is only able to give us a broad perspective on the characteristics of the piece, without elucidating the hierarchy of the different regions in the overall compositional design.To arrive to this, we need to look at the score not as a static network, but as a dynamical graph: a time evolution where the system explores different regimes.A practical way to achieve this is to look at the pcset data in Figure 2 as a time series and exploit the analytical techniques that have been developed to tackle these kinds of data systems.The observation of repetition, clustering and incrementality suggests that time-series data can indeed provide the information on the different regimes, the tonal regions.From this perspective, I analyse the pcset sequence of Figure 2 as a non-stationary signal and apply an algorithm of change point detection and segmentation that uses a cost function with a Gaussian kernel (Truong, Oudre, and Vayatis 2020), as implemented in the ruptures Python package.
It is a sequential approach: first, one change point is detected in the complete input signal, then the series is split around this change point, and the operation is repeated on the two resulting sub-signals (Fryzlewicz 2014).The cost function used in this work is: where y is a multivariate nonstationary signal that in the present work is the mapping of the individual pcsets to a sequence of integers (as shown in Figure 2), so that the signal to segment is one-dimensional, and (b-a) is the length of the sub signal y a ... b .
In Figure 2 I show the partitioning of the time series of the pcsets with vertical lines that correspond to the breaking points.I identify 11 different regions (0-10), where each segment corresponds to a chord range identified by the breaking points at the following bars: 32, 58, 63,101,120,150,166,181,187,207.With these results in hand, we can now proceed to the analysis of each individual region as a network to capture the structure of pcset interactions in a window of time.The result of this process is summarized in Figure 5, which displays the partitioning of the score as a multi-layered network, where each layer displays the connectivity of the pcsets in the range of bars identified above by the segmentation algorithm.
Each layer displays different structures, where different groups of nodes are connected at different times, and the inter-layer links indicate the pcsets that act as pivot chords between different tonal regions.For instance, in layer 0, that can be identified with the beginning section of the string quartet in E major (and indeed the E major triad has the highest degree here, hence is a hub in the power-law sense) the G minor triad plays a very small role in the overall geometry of the layer network, but it becomes the most important node in the next layer, where Beethoven actually modulates to G minor.The vertical links between layers show the common nodes in the two networks and thus the connection between the folds of the scale planes: 0 expresses the chord structure of the E Major scale, and 1 the chord structure of the G minor scale.
We can now apply the same analytical techniques that we considered for the full score network to these layer networks.The subdivisions of the score network now acquire a more definite musical meaning, reflecting the harmonic evolution of the compositional design.Before we move to the quantification of the harmonic content it is important to make some observations that are at the same time structural and stylistic.Given the finite nature of the score, some subnetworks are comprised of very few nodes (see for instance layers 2 and 8), an indication of regions of the composition where there is less harmonic movement in preparation for more dramatic transitions.Of the more articulated sections, the ones that last longer and thus are comprised of more nodes and edges, still display a structure centred around a few main nodes (hubs with larger degree) and their degree distribution still largely follows a power-law distribution that reflects their scale-free properties.This is evidence of the referentiality character of tonal harmony and of hierarchical structure: these properties manifest in the self-similarity characteristics of the tonal progressions.
The determination of the score sections and their representation as layer networks allows us to quantify the relationships between the different regions using well established algorithms for graph similarity measurements.Here I use a graph distance metric based on the maximal common subgraph, as originally proposed in Bunke and Shearer (1998) and implemented in the GMatch4py python library.The results of the comparisons between the layer networks of the sections are shown as a heat map in Figure 6.
Before we analyse these results more closely, we can relate the individual degree distribution of the layer networks to the attribution of a particular tonal character (key) of the individual regions.Given the predominance of the tonic and dominant in tonal music, we assume that the most frequently visited pcsets in each subnetwork are either major or minor triads or dominant seventh chords (see also Pardo and Birmingham 2002).With this proviso, we obtain the assignment of the tonal regions shown in Table 1.The partitions identified by our algorithm agree well with the expert analysis of the score from the ABC-1.0data (Neuwirth et al. 2018), as it will be reviewed more in depth in the discussion of the full score analysis in Section 5 below.
A comparison between the key region assignments and the similarity map for the sub-networks shows a greater variability than one might naively expect: even regions that have the same tonal character might show a relatively low similarity score.Notable exceptions are layers 0, 8 and 10 (the regions in the predominant key of E major) that have a similarity score of about 0.8 (they show an 80% overlap).Of course, stylistic considerations play a central role here, since the observed variability serves as an expressive tool in the development of the composition.Moreover, also the definition of "prevalent chord" will have to be adapted to the particular style or historical period.Finally, the determination of the tonal regions allows for the straightforward application of computational analysis tools, such as the ones in music21, for the identification of the chord types and their roman numeral representation (Tymoczko et al. 2019).

Score analysis, calibration and uncertainty quantification
So far, we have discussed the general principles behind our dynamical score network approach for harmonic analysis using the first movement of Beethoven's string quartet Op. 127, n. 12 without optimizing the two most important free parameters that enter into the algorithm.To summarize: first, in order to speed up the computational analysis we filter the chord sequence exemplified in Figure 3.This procedure allows for a reduction of the number of pcsets in the time series, and in general does not influence the outcome of the analysis if the threshold is kept lower than 10%: most of the rare pcsets arise from the usage of passing tones.Second, and most important, are the parameters that enter into the segmentation algorithm.When the number of change points is unknown, the binary change point detection algorithm uses a penalty parameter ( > 0) that increases (smaller penalty) or reduces (larger penalty) the number of breaking points.
Controlling the penalty value allows us to zoom from the harmonic macro-to micro-structure of the composition: if the cost of breaking the series is high (large penalty) we eventually obtain a single section that corresponds to the static network of Figure 5. From there we can basically extract the overall key of the composition (E major in movement 1).Reducing the penalty, the number of breakpoints increases and so does the harmonic partitioning of the score.In all the examples so far, a penalty of 3 was chosen.I optimized this value by requiring that each section would still contain a "central chord" with higher degree and thus could be assigned a clear tonal centre.
To quantitatively explore the accuracy of the partitioning of the dynamical score network, I have compared the result of our analysis with the expert annotations of the Annotated Beethoven Corpus (ABC) (Neuwirth et al. 2018) for all the movement of the string quartet.In order to obtain a fair comparison between the manual annotations and the automatic partitioning, I adjusted the penalty parameter in order to obtain a similar number of partitions in the two sets.The values chosen are thus: 1.8 for movement 1, 2.8 for movement 2, 2.6 for movement 3, and 2.6 for movement 4. On average, the agreement between the ABC and this work is greater than 80%, a remarkable result, considering a certain degree of arbitrariness in the assignment of roman numerals to chords in any composition: Movement 1 matches 81%, movement 2 89%, movement 3 86% and movement 4 77% (see Table S1 in the supplementary online materials for the full analysis of the range of bars that corresponds to different harmonic regions).Moreover, I did not refine the definition of prevalent chord introduced for the automatic key identification, so further alterations can indeed improve upon the present numbers.
To conclude this section, let us revisit the chorale BWV 267 of Figure 1 and run the same algorithm.In general, chorales are very short pieces with a small number of chords (BWV 267 contains only 17 bars and 123 chords of which 52 unique pcsets), a characteristic that makes them relatively poor candidates for analysis based on statistical inference.However, even in this case, our algorithms identify tonal regions with an accuracy of 85% relative to expert annotations by Jones, Tymoczko, and Robb, as provided in the Bach chorale corpus of the music21 package1 (Cuthbert and Ariza 2010;Tymoczko et al. 2019) proving once more the accuracy and flexibility of the method.

Towards a generative model of tonal compositional design
The identification and classification of the dynamical score network as a convincing representation of a composition suggests avenues for the design of autonomous systems for the generation of harmonic progressions.Looking at any score network we can ask ourselves how many links we have to visit in order to complete a full path and travel all the chord progressions at least once.
This is a well-known route optimization problem: to find a shortest closed path or circuit that visits every edge of a graph.When the graph has an Eulerian circuit (a closed walk that covers every edge once), that circuit is an optimal solution.Otherwise, the optimization problem is to find the smallest number of graph edges to duplicate (or the subset of edges with the minimum possible total weight) so that the resulting multigraph does have an Eulerian circuit (Edmonds and Johnson 1973).If we analyse the network of Figure 1 in this context, Bach completes his circuit in 123 steps on a network of 52 nodes and 101 directed links.This means that in Bach's circuit 22 edges have been duplicated.If we run the route optimization algorithm on the same network, we find a minimum circuit length of 110.This minimal path overlaps with the Bach's version.Its shorter length is only due to repetitions of some of the loops in the original score, while the optimal Eulerian path does not allow for double counting.It is important to note that most loops in the graphs can be visited clockwise or counterclockwise without changing the total path length, thus generating multiple "minimal length paths."This allows to retrieve the similarity with the Bach's original straightforwardly (see Figure S3 in SOM for a direct comparison and a more detailed discussion).Since this solution is built imposing a priori the directedness of the underlying tonal harmony, the resulting circuit provides an abstraction of the harmonic evolution of the piece.
So far, this might seem just an interesting observation on a single chorale: how general is this result?In order to answer this question, I ran the route optimization problem on the full Bach corpus of music21, for a total of 433 scores.For each score I compared two distinct cases with Bach's original circuit: the Eulerian path built on the original score network, and an Eulerian path on a randomly generated scale free network with a pcset distribution that parallels one of the original scores.
There are many generators for scale-free networks (Hagberg, Schult, and Swart 2008).In this study we use the original model proposed by Barabasi and Albert (1999).It incorporates two important general concepts, growth and preferential attachment: growth means that the number of nodes in the network increases over time; preferential attachment means that the more connected a node is, the more likely it is to receive new links.Nodes with a higher degree have a stronger ability to grab links added to the network.Both characteristics ensure that the generated network displays scale-free properties and fall into the general taxonomy of tonal harmony, where centrality is a representation of preferential attachment and growth is intrinsic to the dynamical score network concept.It is then straightforward to generate random scale-free networks that can be interpreted as the skeleton of a dynamical score networks.As illustration, Figure 7 shows a Barabasi-Albert network where I have assigned pcsets to nodes following the ranking of the degree distribution of BWV 267.This gives the following for the six highest degree nodes: GBD (degree 13 in BWV 267 and 13 in the Barabasi-Albert network), DF#A (11 and 13, respectively), CEG (10 and 11), ACE (9 and 11), EGB (8 and 8), and DFA (8 and 6).Finally, we run the route optimization algorithm to generate an Eulerian path.From Figure 7 we immediately observe that this new network still maintains some of the characteristics of the original: nodes are distributed in modularity classes that do not deviate much from the original and indicate a division in tonal regions that carries over from the chord distribution.A close inspection of the path also shows the permanence of common progressions inherited from the original network.
To verify the generality of these observations, I performed this procedure for all the scores in the Bach's corpus of music21 and summarized the results in Figure 8.As in the case of the BWV 267 example, the Eulerian paths on the score networks are systematically shorter than in the original versions due to the omission of double-counting loops in the latter (see Figure S4 in SOM for a comparison of original vs. Eulerian length).However, the length distribution of the Eulerian path on the Barabasi-Albert random graphs is remarkably similar to the one on the original score network, although the arrangement of the links is now randomly chosen by the preferential attachment algorithm (see inset of Figure 8).
In order to quantify the "tonal character" of the chord sequence corresponding to the Eulerian path on the random scale-free networks generated with the Barabasi-Albert algorithm, we compare in the main panel of Figure 8 the relative frequency of specific chord progressions, in both the Eulerian path of the original score network and the Barabasi-Albert graph.The analysis shows a remarkable agreement between the occurrence of specific progressions in the two systems.In both cases, the most dominant voice-leading operations correspond to the most common progressions of tonal harmony: V-I, and V7-I, followed by I-iii, IV-vi, I-V, IV-I, ii-IV etc.Indeed, irrespective of the completely different connectivity of the two networks, the very geometrical characteristics of the optimal path point to the origin of the directedness and centrality in tonal compositions as constraints that emerge naturally from the network structure.In particular, the presence of chord "hubs" forces the path to return to these nodes in order to complete the circuit, thus naturally enforcing the existence of harmonic centres.From here, one can envision a compositional design process comprised of the following steps: the generation of a network with the desired topological characteristics, the assignment of a chord distribution to the nodes, and the determination of the optimal path.Of the steps above, the assignment of chords to nodes is definitely a very arbitrary task that can be undertaken in a myriad of ways depending on the choices of the composing agent (being it human or machine).All the characteristics of tonality come into play here: the most obvious, centrality, coincides with the existence of chord hubs, so that highest degree nodes can be assigned to the most prevalent chords (tonic, dominant, etc.) according to one of the numerous fitness models (see for instance Pardo and Birmingham 2002;Navarro-Caceres, Caetano, and Bernardes 2020), functionality scores (Cuthbert and Ariza 2010) in the preferential attachment, according to degree distributions in existing corpora (Moss et al. 2019) or using the relative occurrences in chord progressions, as suggested by the results of this study.However, ultimately this is the composer's aesthetic decision.

Conclusions
This study builds on the concept of network representation of musical spaces and introduces the idea of a composition as a dynamical score network.We have developed an efficient algorithm for the identification of tonal regions that relies only on the topology of the network, characterized the full chord progression of the composition as a route optimization problem, and shown how these principles can be used to devise a generative model of tonal compositional design.

Figure 2 .
Figure2.Time series of the filtered sequence of the normal ordered pcsets from the first movement of the string quartet Op. 127 n. 12 (blue dots).See Section 4 for the explanation of the regions identified by vertical lines.

Figure 3 .
Figure 3. Score network of the first movement of the Beethoven's string quartet Op. 127 n. 12.

Figure 4 .
Figure 4. Loglog plot of the degree distribution in the score network.The magenta line is the best fit to a power law distribution p(x) ∝ x −α where the value of α = 2.53 has been fitted using the powerlaw Python package (Alstott, Bullmore, and Plenz 2014).

Figure 5 .
Figure 5. Different sections of the score as identified by the segmentation algorithm displayed as a multi-layer network.

Figure 6 .
Figure 6.Heat map of the similarity measure between the layer networks.

Figure 7 .
Figure 7. Scale-free network generated with the Barabasi-Albert algorithm including the chord-node assignments and one of the directional Eulerian paths.

Figure 8 .
Figure 8. Main panel: Relative occurrence of chord progressions in the Eulerian paths of the original scores (blue) and in the random scale-free networks generated with the Barabasi-Albert model of preferential attachment (magenta).Inset: comparison between the lengths of the Eulerian circuit for the original (L BWV ) and the Barabasi-Albert (L Barabasi−Albert ) network.

Table 1 .
Assignment of relative tonal regions in the first movement of the string quartet Op. 127 n. 12.