In [15]:
import networkx as nx
from networkx.algorithms import bipartite
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from scipy.stats import powerlaw
%matplotlib inline
sns.set()
all_edges = set()
with open('test_authors.txt') as f:
for line in f:
users = line.replace('\n','').split(',')
for user1 in users:
for user2 in users:
if ((user1,user2) not in all_edges and (user2,user1) not in all_edges) and (user1 != user2):
all_edges.add((user1,user2))
edges_file = open('test_users_network.txt', 'w')
print('source\ttarget', file=edges_file)
for k, v in sorted(all_edges):
print(k+'\t'+v, file=edges_file)