Updated 3 years ago
import networkx as nx
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline
from google.colab import drive
drive.mount('/content/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:
f.readline()
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')