Math Horizons
Total Page:16
File Type:pdf, Size:1020Kb
Andrew Beveridge and Jie Shan he international hit HBO First, a quick introduction to series Game of Thrones, Game of Thrones: Westeros and adapted from George R. R. Essos, separated by the Narrow Martin’s epic fantasy novel Sea, are homes of several noble T series A Song of Ice and houses (fi gure 1). The narrative Fire, features interweaving plotlines starts at a time of peace, with all and scores of characters. With so the houses unifi ed under the rule of many people to keep track of in this King Robert Baratheon, who holds sprawling saga, it can be a challenge the Iron Throne. Early on, King to fully understand the dynamics Robert dies in a hunting accident, between them. and the young, cruel Prince Joff rey To demystify this saga, we turn to ascends the throne, backed by his network science, a new and evolving mother’s house, Lannister. However, branch of applied graph theory the prince’s legitimacy, and even his that brings together traditions from identity, are seriously questioned many disciplines, including sociology, across the kingdom. As a result, war economics, physics, computer science, breaks out, with multiple claimants and mathematics. It has been applied Helen Sloan/HBO to the Iron Throne. broadly across the sciences, the social sciences, the Driven by cause or circumstance, characters from humanities, and in industrial settings. the many noble families launch into arduous and In this article we perform a network analysis of intertwined journeys. Among these houses are the Game of Thrones to make sense of the intricate honorable Stark family (Eddard, Catelyn, Robb, character relationships and their bearing on the future Sansa, Arya, Bran, and Jon Snow), the pompous plot (but we promise: no spoilers!). Lannisters (Tywin, Jaime, Cersei, Tyrion, and Joff rey), the slighted Baratheons (led by Robert’s brother Stannis) and the exiled Daenerys, the last of the once- powerful House Targaryen. The Social Network Our fi rst task is to turn the Game of Thrones world into a social network. Our network, shown in fi gure 2, has sets of vertices V and edges E. The 107 vertices represent the characters, including ladies and lords, guards and mercenaries, councilmen and consorts, villagers and savages. The vertices are joined by 353 integer-weighted edges, in which higher weights correspond to stronger relationships between those characters. We generated the edges using A Storm of Swords, Figure 1. The Game of Thrones world: Westeros, the third book in the series. We opted for this volume the Narrow Sea, and Essos (from left to right). Sigils represent the locations of the noble houses at the because the main narrative has matured, with the beginning of the saga. characters scattered geographically and enmeshed in 18 April 2016 : : Math Horizons : : www.maa.org/mathhorizons Karl Craster Eddison Qhorin Orell Gilly Rattleshirt Grenn Ygritte Bowen Nan Jojen Hodor Janos Luwin Meera Samwell Mance Aemon Alliser Bran Styr Jon Dalla Theon Val Rickon Melisandre Jeyne Roslin Anguy Shireen Cressen Edmure Eddard Davos Lothar GendryThoros Salladhor Hoster Beric Illyrio Walder Robb Stannis Daario Belwas Drogo Rickard Arya Jorah Brynden Catelyn Sandor Barristan Irri Missandei Ramsay Roose Jon Arryn Walton Robert Daenerys Brienne Rhaegar Aerys Kraznys Worm Petyr Lysa Jaime Viserys Rakharo Aegon Robert Arryn CerseiTywin Elia Marillion Renly Balon Kevan Lancel Sansa Figure 2. The social network Qyburn Joffrey Gregor Shae generated from A Storm of Loras Varys Chataya Swords. The color of a vertex Pycelle indicates its community. The size of a vertex corresponds to Olenna Margaery Tyrion Doran its PageRank value, and the size Mace Meryn Oberyn of its label corresponds to its Tommen Amory EHWZHHQQHVVFHQWUDOLW\$QHGJH·V Myrcella PodrickBronn Ilyn thickness represents its weight. Ellaria their own social circles. We parsed the ebook, incre- companions, Jon Snow and the far North, Stannis’s menting the edge weight between two characters when forces, and Daerenys and the exotic people of Essos. their names (or nicknames) appeared within 15 words Remarkably, these communities were identifi ed from of one another. Afterward, we performed some manual only the network structure, as we explain below. validation and cleaning. Note that an edge between We want to divide the network into coherent commu- two characters doesn’t necessarily mean that they are nities, meaning that there are many edges within com- friends—it simply means that they interact, speak of munities and few edges between communities. We detect one another, or are mentioned together. our network communities by using a global metric called The complex structure of our network refl ects the modularity. Let denote the weight of the edge interweaving plotlines of the story. Notably, we ob- between vertices i and j, where when there is serve two characteristics found in many real-world no edge. Let denote the weighted degree networks. First, the network contains multiple denser of vertex i. Intuitively, the modularity Q compares our subnetworks, held together by a sparser global web of given network to a network with the same weighted edges. Second, it is organized around a subset of highly degrees, but in which all edges are rewired at random. infl uential people, both locally and globally. We now This random network should be community-free, so it describe how to quantify these observations using the makes a good baseline for comparison. analytical tools of network science. Suppose that vertices i and j belong to the same com- munity C. We would expect that wij is at least as large Community Detection as the number of edges between them in our randomly The network layout and colors in fi gure 2 clearly rewired network. A touch of combinatorial probability identify seven communities: the Lannisters and King’s shows that the expected number of such random edges Landing, Robb’s army, Bran and friends, Arya and is where m is the total number of edges in www.maa.org/mathhorizons : : Math Horizons : : April 2016 19 Robert 9 14 9 8 3 2 Robert Stannis 11 13 11 14 6 7 Stannis Cersei 7 10 5 9 10 13 Cersei Jaime 5 4 3 6 6 8 Jaime Joffrey 9 8 6 12 12 14 Joffrey Tyrion 1 1 1 1 1 3 Tyrion Tywin 6 11 8 7 9 10 Tywin Arya 8 7 7 10 5 9 Arya Bran 11 5 13 13 13 11 Bran Catelyn 9 12 10 11 11 12 Catelyn Jon 2 2 12 2 6 1 Jon Robb 4 6 4 4 4 5 Robb Sansa 2 3 2 3 2 6 Sansa Daenerys 11 9 14 5 14 4 Daenerys 0360 550 0 1.0 0 0.04 0 4.5 0 1,275 Degree Weighted Degree Eigenvector PageRank Closeness Betweenness Figure 3. Centrality measures for the network. Larger values correspond to greater importance, except for closeness centrality, where smaller values are better. Numbers in the bars give the rankings of these characters. the network. Summing over all vertices in a community Centrality Measures C, we have Network science can also identify important vertices. A person can play a central role in multiple ways. For ex- ample, she could be well connected, be centrally located, or be uniquely positioned to help disperse information or Meanwhile, if C is not actually a community, then influence others. Figure 3 displays the importance of 14 this quantity may be negative. The modularity Q of a prominent characters, according to six centrality mea- vertex partition C ,…,C of the network is 1 l sures, which we explain below. Degree centrality is the number of edges incident with the given vertex. Weighted degree centrality is defined similarly by summing the weights of the incident edges. where we have normalized this quantity so that In our network, degree centrality measures the number of connections to other characters, while weighted degree Our goal is to partition the vertices into communities centrality measures the number of interactions. so as to maximize Q. Finding this partition is compu- Eigenvector centrality is weighted degree centrality tationally difficult, so we use a fast approximation with a feedback loop: A vertex gets a boost for being algorithm called the Louvain method. connected to important vertices. The importance xi of Crucially, the algorithm determines the number vertex i is the weighted sum of the importance of its of communities; it is not an input. In our case, we neighboring vertices: for each discover the seven communities in figure 2. The King’s Solving the resulting linear system gives the eigenvec- Landing community accounts for 37 percent of the tor centrality. (This name comes from linear algebra: network. When we perform community detection on We actually find an eigenvector for eigenvalue of this major subnetwork, we obtain four communities. the matrix W with entries wij.) A high resolution version of figure 2 and the network Let’s compare the weighted degree and eigenvec- of subcommunities of King’s Landing can be found at tor centralities for our network. The late King Robert maa.org/math-horizons-supplements. receives a huge boost: He has only 18 connections, 20 April 2016 : : Math Horizons : : www.maa.org/mathhorizons but half of them are to other prominent players! Most where is the number of (j,k)-shortest paths and leading characters also benefit from the feedback loop, is the number of these (j,k)-shortest paths that being directly involved in the political intrigue and go through vertex i. A vertex that appears on many sweeping military turmoil that grips the realm. The short paths is a broker of information in the network: exceptions are isolated from the main action: Bran Efficient communication between different parts of (presumed dead and on the run), Jon Snow (marginal- the network will frequently pass through such a vertex.