In [10]:
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('Relacion_autores.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) and (user1 != "") and (user2 != ""):
                    all_edges.add((user1,user2))
    
edges_file = open('users_network.txt', 'w')


for k, v in sorted(all_edges):
    print(k+';'+v, file=edges_file)

In [ ]:


In [11]:
all_edges_gephi = set()
with open('Relacion_autores.txt') as f:
    for line_gephi in f:
        users_gephi = line_gephi.replace('\n','').split(',')
        for user1_gephi in users_gephi:
            for user2_gephi in users_gephi:
                if ((user1_gephi,user2_gephi) not in all_edges_gephi and (user2_gephi,user1_gephi) not in all_edges_gephi) and (user1_gephi != user2_gephi) and (user1_gephi != "") and (user2_gephi != ""):
                    all_edges_gephi.add((user1_gephi,user2_gephi))
    
edges_file = open('gephi_users_network.txt', 'w')

print('Source;Target;Type', file=edges_file)
for k, v in sorted(all_edges_gephi):
    print(k+';'+v+';'+'undirected', file=edges_file)

In [ ]: