Andrew Beveridge and Jie Shan

he international hit HBO

series Game of Thrones,adapted from George R. R.Martins epic fantasy novelseries A Song of Ice andFire, features interweaving plotlinesand scores of characters. With somany people to keep track of in thissprawling saga, it can be a challengeto fully understand the dynamicsbetween them.To demystify this saga, we turn tonetwork science, a new and evolvingbranch of applied graph theorythat brings together traditions frommany disciplines, including sociology,economics, physics, computer science,and mathematics. It has been appliedbroadly across the sciences, the social sciences, thehumanities, and in industrial settings.In this article we perform a network analysis ofGame of Thrones to make sense of the intricatecharacter relationships and their bearing on the futureplot (but we promise: no spoilers!).

First, a quick introduction to

Game of Thrones: Westeros andEssos, separated by the NarrowSea, are homes of several noblehouses (gure 1). The narrativestarts at a time of peace, with allthe houses unied under the rule ofKing Robert Baratheon, who holdsthe Iron Throne. Early on, KingRobert dies in a hunting accident,and the young, cruel Prince Joreyascends the throne, backed by hismothers house, Lannister. However,the princes legitimacy, and even hisidentity, are seriously questionedacross the kingdom. As a result, warbreaks out, with multiple claimantsHelen Sloan/HBOto the Iron Throne.Driven by cause or circumstance, characters fromthe many noble families launch into arduous andintertwined journeys. Among these houses are thehonorable Stark family (Eddard, Catelyn, Robb,Sansa, Arya, Bran, and Jon Snow), the pompousLannisters (Tywin, Jaime, Cersei, Tyrion, and Jorey),the slighted Baratheons (led by Roberts brotherStannis) and the exiled Daenerys, the last of the oncepowerful House Targaryen.

The Social Network

Figure 1. The Game of Thrones world: Westeros,

the Narrow Sea, and Essos (from left to right). Sigilsrepresent the locations of the noble houses at thebeginning of the saga.18 April 2016 : : Math Horizons : : www.maa.org/mathhorizons

Our rst task is to turn the Game of Thrones world

into a social network. Our network, shown in gure 2,has sets of vertices V and edges E. The 107 verticesrepresent the characters, including ladies and lords,guards and mercenaries, councilmen and consorts,villagers and savages. The vertices are joined by353 integer-weighted edges, in which higher weightscorrespond to stronger relationships between thosecharacters.We generated the edges using A Storm of Swords,the third book in the series. We opted for this volumebecause the main narrative has matured, with thecharacters scattered geographically and enmeshed in

Karl

Craster

Eddison

Gilly

Orell

Qhorin

RattleshirtYgritteBowen

GrennJojenHodor

NanLuwin

Samwell

Meera

Aemon

BranTheon

Robb

Hoster

WalderRickard

BryndenRamsay

Eddard

Walton

Lysa

Robert Arryn

BalonQyburn

Sansa

LorasOlenna

Renly

Daario

Belwas

JorahBarristan

Robert

Daenerys

CerseiTywin

Kraznys WormRakharoAegon

Elia

Kevan

Lancel

Gregor

Tyrion

Shae

VarysPycelle

Doran

MerynMyrcella Podrick Bronn

Oberyn

Community DetectionThe network layout and colors in gure 2 clearlyidentify seven communities: the Lannisters and KingsLanding, Robbs army, Bran and friends, Arya and

Mace

Amory

IlynEllaria

their own social circles. We parsed the ebook, incrementing the edge weight between two characters whentheir names (or nicknames) appeared within 15 wordsof one another. Afterward, we performed some manualvalidation and cleaning. Note that an edge betweentwo characters doesnt necessarily mean that they arefriendsit simply means that they interact, speak ofone another, or are mentioned together.The complex structure of our network reects theinterweaving plotlines of the story. Notably, we observe two characteristics found in many real-worldnetworks. First, the network contains multiple densersubnetworks, held together by a sparser global web ofedges. Second, it is organized around a subset of highlyinuential people, both locally and globally. We nowdescribe how to quantify these observations using theanalytical tools of network science.

Irri

RhaegarViserys

Tommen

Drogo

Missandei

Aerys

JoreyMargaery

Illyrio

Sandor

Jon Arryn

Jaime

Salladhor

Stannis

Beric

BriennePetyr

ShireenCressen

Davos

GendryThoros

Arya

Roose

Dalla

Val

Melisandre

Catelyn

Marillion

Styr

Anguy

Roslin

Edmure

Janos

Alliser

Jon

RickonJeyne

Lothar

Mance

Figure 2. The social network

generated from A Storm ofChatayaSwords. The color of a vertexindicates its community. Thesize of a vertex corresponds toits PageRank value, and the sizeof its label corresponds to itsEHWZHHQQHVVFHQWUDOLW\$QHGJHVthickness represents its weight.

companions, Jon Snow and the far North, Stanniss

forces, and Daerenys and the exotic people of Essos.Remarkably, these communities were identied fromonly the network structure, as we explain below.We want to divide the network into coherent communities, meaning that there are many edges within communities and few edges between communities. We detectour network communities by using a global metric calleddenote the weight of the edgemodularity. Letbetween vertices i and j, wherewhen there isno edge. Letdenote the weighted degreeof vertex i. Intuitively, the modularity Q compares ourgiven network to a network with the same weighteddegrees, but in which all edges are rewired at random.This random network should be community-free, so itmakes a good baseline for comparison.Suppose that vertices i and j belong to the same community C. We would expect that wij is at least as largeas the number of edges between them in our randomlyrewired network. A touch of combinatorial probabilityshows that the expected number of such random edgeswhere m is the total number of edges iniswww.maa.org/mathhorizons : : Math Horizons : : April 2016 19

RobertStannis

911

1413

911

814

CerseiJaimeJoreyTyrionTywin

7591

104

53

10

13

8111

61

61219

8143

61217

75

713

1013

513

10124

11243

1164

12263

9111215

JonRobbSansa

11

14

Daenerys

AryaBranCatelyn

JonRobbSansaDaenerys

6811924

36Degree

214550

Weighted Degree

1.0Eigenvector

27

0.04PageRank

RobertStannisCerseiJaimeJoreyTyrionTywin

10

4.5Closeness

AryaBranCatelyn

1,275Betweenness

Figure 3. Centrality measures for the network. Larger values correspond to greater importance, except for closenesscentrality, where smaller values are better. Numbers in the bars give the rankings of these characters.

the network. Summing over all vertices in a community

C, we have

Meanwhile, if C is not actually a community, then

this quantity may be negative. The modularity Q of avertex partition C1,,Cl of the network is

where we have normalized this quantity so that

Our goal is to partition the vertices into communitiesso as to maximize Q. Finding this partition is computationally dicult, so we use a fast approximationalgorithm called the Louvain method.Crucially, the algorithm determines the numberof communities; it is not an input. In our case, wediscover the seven communities in gure 2. The KingsLanding community accounts for 37 percent of thenetwork. When we perform community detection onthis major subnetwork, we obtain four communities.A high resolution version of gure 2 and the networkof subcommunities of Kings Landing can be found atmaa.org/math-horizons-supplements.20 April 2016 : : Math Horizons : : www.maa.org/mathhorizons

Centrality MeasuresNetwork science can also identify important vertices. Aperson can play a central role in multiple ways. For example, she could be well connected, be centrally located,or be uniquely positioned to help disperse information orinuence others. Figure 3 displays the importance of 14prominent characters, according to six centrality measures, which we explain below.Degree centrality is the number of edges incident withthe given vertex. Weighted degree centrality is denedsimilarly by summing the weights of the incident edges.In our network, degree centrality measures the numberof connections to other characters, while weighted degreecentrality measures the number of interactions.Eigenvector centrality is weighted degree centralitywith a feedback loop: A vertex gets a boost for beingconnected to important vertices. The importance xi ofvertex i is the weighted sum of the importance of itsneighboring vertices:for eachSolving the resulting linear system gives the eigenvector centrality. (This name comes from linear algebra:We actually nd an eigenvector for eigenvalueofthe matrix W with entries wij.)Lets compare the weighted degree and eigenvector centralities for our network. The late King Robertreceives a huge boost: He has only 18 connections,

but half of them are to other prominent players! Most

leading characters also benet from the feedback loop,being directly involved in the political intrigue andsweeping military turmoil that grips the realm. Theexceptions are isolated from the main action: Bran(presumed dead and on the run), Jon Snow (marginalized in the far North), and Daenerys (exiled across theNarrow Sea).PageRank is another variation on this theme. Thismeasure was the founding idea behind Brin and PagesGoogle search engine. Each vertex has an inherentimportancealong with an importance acquiredfrom its neighbors. Unlike eigenvector centrality, avertex does not get full credit for the total importanceof its neighbors. Instead, that neighbors importance isdivided equally among its direct connections. In otherwords, a vertex of very high degree passes along only asmall fraction of its importance to each neighbor.The PageRank yi of vertex i is given by

where

is the number of (j,k)-shortest paths and

is the number of these (j,k)-shortest paths thatgo through vertex i. A vertex that appears on manyshort paths is a broker of information in the network:Ecient communication between dierent parts ofthe network will frequently pass through such a vertex.Such connectors have the potential to be highly inuential by inserting themselves into the dealings of otherparties.Betweenness centrality gives a distinctive rankingof the characters. This is the only measure in whichTyrion does not come out on top: He places third,behind Jon Snow (thanks to his ties to both HouseStark and the remote denizens of the North) andRobert Baratheon (the only person directly connectedto all four noble houses of the leading characters).Meanwhile, Daenarys rises to fourth place (her bestshowing) because of the hub-and-spoke nature of theeclectic Essos community.There is no single right centrality measure for anetwork. Each measure gives complementary informa-

whereandResearchers typicallyuseto nd an eective balance betweeninherent importance and the neighborhood boost.PageRank does not penalize our three far-ungcharacters and actually has the opposite eect onDaenerys. In fact, the PageRank ordering is nearlyidentical to the degree centrality ordering, exceptDaenerys jumps from 12th place to fth place. SoPageRank correctly identies the charismatic Daenerysas one of the most important players, even though shehas relatively few connections.This brings us to two centrality measures whosedenitions take a more global view of the network. Thecloseness centrality of a vertex is the average distancefrom the vertex to all other vertices. (Unlike the othercentrality measures, lower values correspond to greaterimportance.) The closeness values for our list of maincharacters is quite compressed, except for the farawayDaenarys. However, Tyrion and Sansa have a slightedge over everyone else.The nal centrality measure is the most subtle. Thebetweenness centrality of a vertex measures how frequently that vertex lies on short paths between otherpairs of vertices. Mathematically, the betweenness zi ofvertex i is

Jon Snow is uniquely positioned in

the network, with connections tohighborn lords, the Nights Watchmilitia, and the savage wildlingsbeyond the Wall.tion, and taking them in concert can be quite revealing. In our network, three characters stand out consistently: Tyrion, Jon, and Sansa. Acting as the Handof the King, Tyrion is thrust into the center of thepolitical machinations of the capitol city. Our analysissuggests that he is the true protagonist of the book.Meanwhile, Jon Snow is uniquely positioned inthe network, with connections to highborn lords, theNights Watch militia, and the savage wildlings beyondthe Wall. The real surprise may be the prominenceof Sansa Stark, a de facto captive in Kings Landing.However, other players are aware of her value as aStark heir and they repeatedly use her as a pawn intheir plays for power. If she can develop her cunning,then she can capitalize on her network importance todramatic eect.Meanwhile, Robert and Daenarys stand out byoverperforming in certain centrality measures. Theywww.maa.org/mathhorizons : : Math Horizons : : April 2016 21

Directions to Be Read,Then IgnoredGary Gordon and Rebecca Gordon

n writing worksheets, homework assignments, quizzes, and exams, we (the

authors) often take afew liberties with thestandard Do all ofthese problems to thebest of your abilityinstructions at the topof the paper. Here are a fewof the ones weve used, often in reference to the topic ofthe day, but also referring to current events, pop culture,and students in the classand always just plain silly. Like snowakes, no two of these problems areexactly the same. Also like snowakes, they will meltif you touch them. Solve all of these problems withouttouching anything. There is an invisible dog in the room. It will barkuncontrollably if you make a mistake. Good luck! One of these problems was not approved for humanconsumption. If you eat that one by mistake, the antidote is to eat the next problem. (Note: This tells yousomething about which problem might be toxic.) You walk into a doctors oce and say, I need an

provide a clear counterpoint to one another and return

our attention to the Iron Throne itself. Roberts memory unies the crumbling network of the recent past,while Daenarys will surely upend the current networkwhen she returns to Westeros in pursuit of the throne.

A Networked Life

injection. He says, Comment. Why does calculus keep getting harder?Come to think of it, why does everythingkeep getting harder? Classes, friendships, lifeseriously, its everything!These are some intense philosophical questions that wont beanswered on this test.Good luck trying toconcentrate now! As we sit here inthis classroom, a largecomet is speeding towardthe earth. Scientists expectit to hit this building in exactly onehour. Plan your test-taking strategy accordingly. This is the beginning of a long, pointless exerciselike college. Enjoy! You have only 50 minutes for this onedont wastetime reading the directions. QGary and Rebecca Gordon are a father-daughter mathteam. Gary teaches at Lafayette College and is theMath Horizons problems editor. Rebecca teaches mathematics at Newark Academy. The family is publishinga book on the card game SET, called The Joy of SET.Email: gordong@lafayette.eduEmail: rgordon@newarka.eduhttp://dx.doi.org/10.4169/mathhorizons.23.4.22