Network analysis – A Song of Ice and Fire

Networks, Visualization


“A Song of Ice and Fire” more popularly known as “Game of Thrones” is George R.R. Martin’s best-selling book series. It was adapted as a television series and enjoyed widespread popularity. It depicts the internal power struggle to control the Seven kingdoms of a mythical land called Westeros by powerful families amid an external threat of White Walkers and a battle between the living and the dead. This case study analyzes the networks in the first five books using Gephi and aims to understand how the central characters were related to each other.


There were two visualizations that I benchmarked and informed my analysis:

  1. Network of Thrones – A Song of Math and Westeros by Andrew Beveridge. This was based on a network of chracters formed by creating links whenever their names appeared within 15 words of one another. A link thus indicated connection between charcters whenever they spoke to each other, they spoke about someone or they were spoken of together. I liked the use of colors to categorize the clusters and how the egde weight indicated how strong the connection between characters were.

2. Past work of SI students – I was able to find blogs by past students on the same topic as me and I liked how they had created their networks and the thought process which informed their decisions. The first was by Sanchit Kumar, I liked how he had broken down his process clearly and how it gave a holistic overview of the first five books. The second one was by Preet Gangrade, I liked how he had broken down his analysis bookwise and the depth in which he had covered each book.


  1. Gephi – It is an open source software to create network visualization and analysis. This was used to create the network in this case study.
  2. Figma – It is a vector based digital editing tool used that is browser based. The annotations were added using this tool
  3. Dataset – The dataset was based on the first five books of “A Song of Ice and Fire” and was created by linking characters whenever their names (or nicknames) appeared within 15 words of one another. This dataset had 796 (Characters in “A Song of Ice and Fire”) nodes and 2823 edges (Undirected interactions between these characters)


Step 1

I started by making sense of the dataset which was in a CSV format. There were two files one for node and the other for edges. Once I understood the data, I proceeded to import it into Gephi. The tool automatically generated a visualization but it was cluttered and did not make much sense.

Step 2

The next step was to improve the structure of the network. In order to do that, I ran the “Force Atlas 2 “function. After letting the structure get stabilized I selected the “Dissuade Hubs” and “Prevent overlap” options. I also ran the following statistics to enrich my data:

  1. Average Degree
  2. Average Weighted Degree
  3. Graph Density
  4. Network Diameter
  5. Modularity

Step 3

The next step was to add labels and colors to my visualization. While adding the labels the network was too condensed and the text was illegible. I decided to run the “Label Adjust” function which expanded the network to better accommodate the text. For the colors, I decided to group them according to the modularity class. The nodes were sized according to the degree and the edge width was dependent on the strength of the connections. I chose the background color to be black as that went well with the theme.

Step 4

When I was at the last stage of my visualization and had performed all the necessary functions, I was happy with how my visualization looked. However, I felt that the nodes with a lesser degree were making the network too vast to consume, and the actual connection between the main character which was my initial focus was getting lost. Therefore, I decided to apply a filter that would not show the nodes with a degree lesser than 13. This reduced the visible nodes from 796 to 105 and edges from 2823 to 862. I felt that filtering the network was important to convey the essence of the visualization and the viewers would be able to focus more on the central characters.


After my visualization was complete, I found that the two characters most important to the storyline and mentioned the most were Tyrion Lannister and Jon Snow. Now that the show is over we know that they were the two main characters who were well connected to a vast majority of characters. The other characters who had a high degree and were well connected after them were Jaimie and Cersei Lannister.

It was also interesting to note that the strongest connection or edges between characters were those between Robert Baratheon & Eddard stark followed by Jon Snow & Samwell Tarly. As reflected in the storyline these were the characters with the strongest friendships and I was happy to see that was reflected in the data as well.

The other important aspect was how the modularity class created by the software was consistent with the story and geographic locations. For example the grouping between the Night’s watch, King’s landing or Essos. This makes sense as the characters who were in the same location must have had the most interactions with each other and the strongest links. An exception to this would be the relationship between Arya and Sansa Stark as they were physically separated early on but still kept in touch.


I enjoyed working on this project and really liked how the visualization created using data, backed the storyline, and made sense. I would have liked it if the tools inside Gephi were more user-friendly and provided more explanation about what they did. It took a while for me to understand the functions and their usage. Also, I would echo the sentiment of the other students and say that the lack of the undo button was very cumbersome and it should be integrated to allow for greater experimentation.