import matplotlib.pyplot as plt

import networkx as nx

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
from subprocess import check_output
comments = pd.read_csv('../input/comment.csv')
likes = pd.read_csv('../input/like.csv')
members = pd.read_csv('../input/member.csv')
posts = pd.read_csv('../input/post.csv')

likeResponse = pd.merge(likes.loc[likes['gid'] == 117291968282998], posts.loc[posts['gid'] == 117291968282998, ['pid', 'name']], left_on='pid', right_on='pid')
result = likeResponse.groupby(['name_y', 'name_x'])['response'].count()
finalResult = pd.DataFrame(result.index.values, columns=['NameCombo'])
finalResult['Weight'] = result.values
finalResult['From'] = finalResult['NameCombo'].map(lambda x: x[0])
finalResult['To'] = finalResult['NameCombo'].map(lambda x: x[1])
del finalResult['NameCombo']
g = nx.Graph()
g.add_edges_from([(row['From'], row['To']) for (index, row) in finalResult.iterrows()])
d = nx.degree(g)
spring_pos = nx.spring_layout(g)
plt.axis('off')
plt.clf()

g.number_of_nodes()
spring_pos = nx.spring_layout(g, scale=2)
nx.draw(g, spring_pos, with_labels=False, nodelist=d.keys(), node_size=[v * 5 for v in d.values()])