<<

Andrew Beveridge and Jie Shan he international hit HBO First, a quick introduction to series , Game of Thrones: Westeros and adapted from George R. R. Essos, separated by the Narrow Martin’s epic 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 Baratheon, who holds sprawling , 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 , a new and evolving mother’s house, Lannister. However, branch of applied graph theory the prince’s , 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 family (Eddard, Catelyn, Robb, character relationships and their bearing on the future Sansa, Arya, Bran, and ), 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 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 , 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 , 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 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 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 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 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. ized in the far North), and Daenerys (exiled across the Such connectors have the potential to be highly influ- Narrow Sea). ential by inserting themselves into the dealings of other PageRank is another variation on this theme. This parties. measure was the founding idea behind Brin and Page’s Betweenness centrality gives a distinctive ranking Google search engine. Each vertex has an inherent of the characters. This is the only measure in which importance along with an importance acquired Tyrion does not come out on top: He places third, from its neighbors. Unlike eigenvector centrality, a behind Jon Snow (thanks to his ties to both House vertex does not get full credit for the total importance Stark and the remote denizens of the North) and of its neighbors. Instead, that neighbor’s importance is (the only person directly connected divided equally among its direct connections. In other to all four noble houses of the leading characters). words, a vertex of very high degree passes along only a Meanwhile, Daenarys rises to fourth place (her best small fraction of its importance to each neighbor. showing) because of the hub-and-spoke nature of the

The PageRank yi of vertex i is given by eclectic Essos community. There is no single “right” centrality measure for a network. Each measure gives complementary informa- where and Researchers typically Jon Snow is uniquely positioned in use to find an effective balance between inherent importance and the neighborhood boost. the network, with connections to PageRank does not penalize our three far-flung characters and actually has the opposite effect on highborn lords, the Night’s Watch Daenerys. In fact, the PageRank ordering is nearly militia, and the savage wildlings identical to the degree centrality ordering, except Daenerys jumps from 12th place to fifth place. So beyond the Wall. PageRank correctly identifies the charismatic Daenerys as one of the most important players, even though she tion, and taking them in concert can be quite reveal- has relatively few connections. ing. In our network, three characters stand out con- This brings us to two centrality measures whose sistently: Tyrion, Jon, and Sansa. Acting as the Hand definitions take a more global view of the network. The of the King, Tyrion is thrust into the center of the closeness centrality of a vertex is the average distance political machinations of the capitol city. Our analysis from the vertex to all other vertices. (Unlike the other suggests that he is the true protagonist of the book. centrality measures, lower values correspond to greater Meanwhile, Jon Snow is uniquely positioned in importance.) The closeness values for our list of main the network, with connections to highborn lords, the characters is quite compressed, except for the faraway Night’s Watch militia, and the savage wildlings beyond Daenarys. However, Tyrion and Sansa have a slight the Wall. The real surprise may be the prominence edge over everyone else. of , a de facto captive in King’s Landing. The final centrality measure is the most subtle. The However, other players are aware of her value as a betweenness centrality of a vertex measures how fre- Stark heir and they repeatedly use her as a pawn in quently that vertex lies on short paths between other their plays for power. If she can develop her cunning, pairs of vertices. Mathematically, the betweenness zi of then she can capitalize on her network importance to vertex i is dramatic effect. Meanwhile, Robert and Daenarys stand out by overperforming in certain centrality measures. They

www.maa.org/mathhorizons : : Math Horizons : : April 2016 21 injection.” He says, “ ” Comment. Directions to Be Read, » Why does calculus keep getting harder? Then Ignored Come to think of it, why does everything keep getting harder? Classes, friend- Gary Gordon and Rebecca Gordon ships, life—seriously, it’s everything! n writing worksheets, homework assign- These are some intense philo- ments, quizzes, and exams, we (the sophical questions that won’t be authors) often take a answered on this test. few liberties with the Good luck trying to standard “Do all of concentrate now! Ithese problems to the » As we sit here in best of your ability” this classroom, a large instructions at the top comet is speeding toward of the paper. Here are a few the earth. Scientists expect of the ones we’ve used, often in reference to the topic of it to hit this building in exactly one the day, but also referring to current events, pop culture, hour. Plan your test-taking strategy accordingly. » This is the beginning of a long, pointless exercise— and students in the class—and always just plain silly. like college. Enjoy! » Like snowflakes, no two of these problems are » You have only 50 minutes for this one—don’t waste exactly the same. Also like snowflakes, they will melt time reading the directions. if you touch them. Solve all of these problems without Q touching anything. Gary and Rebecca Gordon are a father-daughter math » There is an invisible dog in the room. It will bark team. Gary teaches at Lafayette College and is the uncontrollably if you make a mistake. Good luck! Math Horizons problems editor. Rebecca teaches math- » One of these problems was not approved for human ematics at Newark Academy. The family is publishing consumption. If you eat that one by mistake, the anti- a book on the card game SET, called The Joy of SET. dote is to eat the next problem. (Note: This tells you Email: [email protected] something about which problem might be toxic.) Email: [email protected] » You walk into a doctor’s office and say, “I need an http://dx.doi.org/10.4169/mathhorizons.23.4.22

provide a clear counterpoint to one another and return [2] D. Easley, J. Kleinberg. Networks, Crowds and our attention to the Iron Throne itself. Robert’s mem- Markets. Cambridge University Press, Cambridge, ory unifies the crumbling network of the recent past, 2010. while Daenarys will surely upend the current network [3] S. Fortunato. Community detection in graphs. when she returns to Westeros in pursuit of the throne. Physics Reports 486 nos. 3–5 (2010) 75–174. [4] M. Newman, Networks: An Introduction. Oxford A Networked Life University Press, Oxford, 2010. We have visited the realms of Westeros and Essos to tour the basic tools of network science. We performed an empirical analysis of our network, finding commu- nities and identifying influential people. Our network analysis confirmed some expectations and provided new insights into this richly imagined saga. We have considered a fanciful application of network science to give an enticing taste of its capabilities. More serious applications abound, and network science promises to be invaluable in understanding our modern networked life. Q

Further Reading [1] A.-L. Barabási, Network Science. barabasilab.neu. edu/networksciencebook/downlPDF.html. http://dx.doi.org/10.4169/mathhorizons.23.4.18

22 April 2016 : : Math Horizons : : www.maa.org/mathhorizons