Learn practical skills, build real-world projects, and advance your career
Python version: >=3.7
Networkx version: >=2.3
Last update: 24/11/2021

Chapter 3: Ties Strength & Resilience

Note: this notebook is purposely not 100% comprehensive, it only discusses the basic things you need to get started.

import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

%matplotlib inline
from google.colab import drive

Reading Game of Thrones Season 6 edge data and defining the graph g (useful for further operations).

Download data from here.

weight is the number of interactions between the characters.

def read_net_w(filename):
    g = nx.Graph()
    with open(filename) as f:
        for l in f:
            l = l.split(",")
            g.add_edge(l[0], l[1], weight=int(l[2]))
    return g

# Game of Thrones data
season = 6
g = read_net_w(f'/content/drive/MyDrive/LeADS/course_network_science/data/asioaf/got-s{season}-edges.csv')