The Graph of Thrones [Season 7 Contest]

 By Michael Hunger, Developer Relations | July 16, 2017
Today launches the seventh season of “Game of Thrones” with many exciting developments awaiting the audience. Even if we might never see the last two books Winds of Winter and A Dream of Springpublished, the TV series producers march ahead and have created their version of events in Westeros.

So like everyone else, we encourage you to become part of the Game of Thrones activities in the next two months.

Publish Graph + Game of Thrones Content = Win Prizes

If you create or publish graphy Game of Thrones content that uses Neo4j, graph visualizations, graph algorithms, combines datasets or any other interesting variants, you’ll be eligible for our weekly GoT prize.

The prize is a Game of Thrones T-shirt of your choice plus EUR 50 worth of GoT paraphernalia (sorry, no swords), e.g., from Elbenwald or similar outlets.

For instance a bag that shows your allegiance to House Stark.

got bag

We’ll award seven of these prizes while the series runs, with the first going to Tomaz Bratanic for his already amazing, ongoing blog post series.

If you have any questions around this challenge, please join our Slack Group and ask in the #game-of-thrones channel.

Graph Visualizations of Westeros

As you might have already noticed, the complexity of relationships in the world of Westeros demands a graph visualization.

hbos game of thrones 50290f9cae135 w1500

I am always impressed how applying network analytics on this dataset yields similar insights as reading and understanding the books would give us in terms of relevance of people and events.

First Game of Thrones GraphGists

The first, very basic graph of the Houses of Westeros was for the Neo4j Console which was then soon followed by an accompanying GraphGist.

Here is a much larger dataset, that was also published as a GraphGist.

The%20Game%20of%20Thrones%20in%20Neo4j%20 %20Neo4j%20GraphGist

Teaching Graphs with Game of Thrones

We also used Game Of Thrones to teach graph databases at Women Who Code workshops in London.

My colleague Mark Needham scraped the GoT Wikia data (and some more sources) to use as the dataset.

game of graphs

You can find the data and code here and run the Neo4j Browser guide with :play https://guides.neo4j.com/got_wwc

Analysing GoT Character Co-Occurences

Will Lyon published a Network Analysis of the Game of Thrones based on a dataset of character co-occurences in the third book, A Storm of Swords, published by Andrew Beveridge and Jie Shan.

Will imported the data into Neo4j and shows how to gain insight into the relevance and connections of people by just running a few queries and graph algorithms. You can run the same data in your Neo4j Browser using :play http://guides.neo4j.com/got

game of thrones graph visualization

I’m extremely excited that Andrew just tweeted yesterday that they now have all five of the Song of Ice and Fire books processed and the data published.

Winter is coming in 2 days. Check out my network analysis of all 5 books.  https://networkofthrones.wordpress.com   

Photo published for Network of Thrones

Network of Thrones

A Song of Math and Westeros

networkofthrones.wordpress.com

I’m looking forward to this new data being imported and analysed. With both the graph algorithms in APOC and the new neo4j-graph-algorithms library, this should be easy.

Analysing Kaggle Data

As mentioned in the beginning, Tomaz Bratanic did a great job already in his Game of Thrones series to import the data from Kaggle into Neo4j. And now with his fourth post, he started to analyse it to draw the first insights around battles, deaths and allegiances.

An excerpt from blog post number four in the series:

…​

Create a network of persons that fought on the same side in the year 299.

MATCH (p1:Person)-[r1]-(b:Battle {year:299})-[r2]-(p2:Person)
WHERE type(r1)=type(r2)
MERGE (p1)-[:FRIEND]-(p2)

Run the algorithms and write back the results as a property of the node community.

CALL algo.unionFind('Person', 'FRIEND', {write:true, partitionProperty:"community"});

Show the results of the computation.

MATCH (p:Person)
RETURN p.community as community, collect(p.name) AS members, count(*) AS count
ORDER BY count DESC LIMIT 10
screen shot 2017 07 14 at 16 11 52

We observe that 10 different communities (partitions) exist. It is a good representation of the state of alliances that fought together in that specific year. We could do this analysis for a couple of different years and compare alliances over the years on how they change.

…​

So have fun watching the new Game of Thrones season, and if you haven’t already, then don’t forget to read the books as well.

And instead of feverishly awaiting the next episode, publish some graph fun with Game of Thrones data and you could be one of our lucky winners.

Cheers,
Michael

About the Author

Michael Hunger, Developer Relations

Michael Hunger ImageMichael Hunger has been passionate about software development for a very long time. For the last few years he has been working with Neo Technology on the open source Neo4j graph database filling many roles. As caretaker of the Neo4j community and ecosystem he especially loves to work with graph-related projects, users and contributors. As a developer Michael enjoys many aspects of programming languages, learning new things every day, participating in exciting and ambitious open source projects and contributing and writing software related books and articles.

Sponsored by Neo4j

You may also like...