Introduction
Game of thrones is a fantasy TV series on HBO based on a series of fantasy novels “A Song of Ice and Fire” written by George R. R. Martin. Although the novels have five volumes in total the TV series is spread across eight seasons with a total of 73 episodes. This story has a plethora of characters spread across several kingdoms in a fictional world. In this lab I have attempted to create a network graph of the interactions between the characters in this series. Furthermore I have grouped the clusters and created a hypergraph which shows the major themes that are followed throughout the TV series.
Inspiration
I found similar work done by Network of Thrones & Pratt iSchool students (work 1, work 2). All these works followed a similar pattern in creating the network graph in some way. When I looked at the network graphs done by Network of Thrones, I liked the way in which the network was clustered and the characters were grouped in these clusters. It represented the regions in the fictional world of this series where the characters interacted with each other.
The past work on this topic by Pratt iSchool students was mainly focused on the novel series and not the TV Series. These graphs included book by book networks as well as a cumulative network from all the books.
I decided to take this idea a step further by not only creating a network graph for the cumulative eight seasons of the TV series but also creating a network hypergraph for the same.
Softwares, Tools & Datasets
Datasets: I used the same datasets as that of Network of Thrones which is hosted on their GitHub. Since this dataset was split by series, I had to create the cumulative dataset manually.
Python: I used the python programming language to create the dataset for the cumulative eight seasons as well as for creating the datasets for the hypergraphs. In doing this I used the csv module for python.
Gephi: I used Gephi for creating the network graph visualizations. It is a free tool which provides a wide range of plugins and layouts for varied uses.
Method
The process of creating the network graphs included the following steps:
Step 1 – Dataset Creation
I wanted to create a single dataset for all the seasons of the TV series since the available dataset were split by seasons. This was so to make sure that the dataset is clean for creating the graph networks. I started by downloading the nodes and edges dataset for all the individual seasons from the project done by Network of Thrones. For joining all the nodes data I wrote a simple python script. For the edges data, I just needed the source, target and weight columns from all the seasons. I again wrote a python script to make the compiled edges data. These scripts are hosted on my GitHub repository for this project.
Step 2 – Creating Network Graph
Once the nodes and edges csv files were created, I imported these files as spreadsheets into Gephi and calculated the average degree, weighted degree, network diameter and modularity for this graph. Calculating these statistics is just a button click each in Gephi.
After I had the statistics calculated, I ran the Fruchterman Reingold algorithm to get a network layout. Since the network turned out to be very dense, I then ran the expansion algorithms three times. These algorithms are by default available in Gephi. Once I had a layout of the network, I sized the nodes by their degree and partition colored them using the modularity class.
I then previewed the network and added labels to the nodes in white and made the background color black. The black background made the network colors more visually appealing. I then exported the network visualization.
Step 3 – Creating Data Sheets for Hypergraph
For making the hypergraph nodes and edges, I first exported the nodes and edges data from the primary network graph with all the statistics calculated as mentioned before. Then I replaced the source and target ids from the edges data with respective modularity classes of those ids from the nodes data. Further I created the nodes data for hypergraph which had the modularity classes as ids and the number of nodes in each modularity class in the primary graph as the size. I wrote a simple python script to achieve all these steps for creating the hypergraph datasheets.
Step 4 – Creating the Hypergraph
I imported the hypergraph nodes and edges csv datasheets into Gephi. In the nodes datasheet I labeled the ids with the same classes as done by Network of Thrones for the modularity classes on their network. Then I used the circular layout to create the network graph. This circular layout was not available by default, so I used a Gephi plugin to download this layout. I then changed the background to black and the labels to white the same as the primary network graph. I also used similar colors to represent the nodes in the hypergraph analogous to the modularity classes in the primary graph. Finally I exported the network visualization graph.
Results & Interpretation
#1 Season 1-8 Network Graph
This network graph is consistent with the TV series with its most prominent character nodes having greater degree than the others which in turn translates to bigger size of the respective nodes in this graph. The modularity classes are also consistent with the story flow of the series as well as the regions in which the characters interact with each other in the TV series. Some clusters (like that which include Cersie, Danaerys, Jon, Theon) can also be roughly grouped as respective geographic regions in the fantasy world of this series. Some other clusters (like that which include Sansa, Arya) are formed around characters that move around different regions in this fantasy world. This observation led me to make the hypergraph for this network.
#2 Season 1-8 Hypergraph
This hypergraph is representative of the previous network graph. The nodes in this graph represent the clusters in the previous network graph. The nodes in this graph have similar color to that of the clusters in the previous graph.
The labels of the nodes and the representing clusters are as follows:
- Essos: (Daenerys, Jorah) cluster
- Jon’s ALliance: (Jon, Sam, Davos) cluster
- Arya’s Journey: (Arya, Sandor) cluster
- Littlefinger’s Game: (Sansa, Ned) cluster
- King’s Landing: (Tyrion, Cersie, Jaime) cluster
- Houses Stark, Greyjoy and Tully: (Theon, Bran, Catelyn) cluster
There are three more nodes formed in the hypergraph, these nodes represent the outliers in the previous graph and have a small enough size to ignore them.
Reflection & Future Direction
I enjoyed creating the network graphs and visualizing the characters and their connections throughout the show as graphs. Since the final results confirm with the storyline of the TV series I consider this experiment a success. I have a couple directions where I would like to take this project in the future.
- Season wise networks of the TV series: I would like to do a season wise network graph of this TV series and see how the graphs change season-to-season. It would be an interesting experiment to compare the changes in the network graph as we follow the TV series and finally compare them with the cumulative network graph.
- Network Graph for novel series: I would also like to do a book wise network graph and do a similar comparison as for the TV series graph networks. It would also be interesting to see how similar or different the TV series and novel series graphs are from each other.
References
https://networkofthrones.wordpress.com/the-series/seasons-1-8/
https://studentwork.prattsi.org/infovis/visualization/network-analysis-a-song-of-ice-and-fire/
https://studentwork.prattsi.org/infovis/visualization/visualizing-game-of-thrones-a-song-of-ice-and-fire-book-wise-analysis/
https://gephi.org