Lect 06 Network Analysis with Networkx Working with Data sets
Channel: Data Science Center
Date: 26/05/2022

Lect 06 Network Analysis with Networkx Working with Data sets

import networkx as nx
import pandas and pd
import matplotlib.pyplot as plt


user = ['user_from', 'user_to', 'trust']
df = pd.read_csv('E:/RSAlgorithms-master/ft_trust.txt', sep= ' ', names= user )

df.head()

G = nx.from_pandas_edgelist(df, source='user_from', target='user_to',edge_attr = 'trust', create_using= nx.DiGraph)

pos = nx.spring_layout(G)
plt.figure(figsize=(13, 13))
nx.draw_networkx_edge_labels(G,pos=pos, edge_labels=trust, font_size= 12 )
nx.draw_networkx(G, pos, with_labels=True, node_color='r', edge_color='g', node_size=1200, arrowsize= 30)
plt.show()