# -*- coding: utf-8 -*-
import networkx as nx
import random

def get_randomized_network(original_network):
	nx_rand_graph = nx.DiGraph()
	listaNodes = original_network.nodes()
	nx_rand_graph.add_nodes_from(listaNodes)

	numberEdgesOriginal = 0
	for n,nbrs in original_network.adjacency_iter():
		for nbr,eattr in nbrs.items():
		   peso=eattr['weight']
		   numberEdgesOriginal = numberEdgesOriginal +peso

	print numberEdgesOriginal
	
 
	for i in range(0, numberEdgesOriginal):
		
		random_node1 = random.randint(0, len(listaNodes)-1)
		random_node2 = random.randint(0, len(listaNodes)-1)

		if nx_rand_graph.has_edge(random_node1,random_node2):

			valor = nx_rand_graph[random_node1][random_node2]['weight']
			valor = valor +1
			nx_rand_graph[random_node1][random_node2]['weight'] = valor
		else:
			nx_rand_graph.add_edge(random_node1, random_node2,weight=1)
		
	return nx_rand_graph



if __name__ == '__main__':

	G=nx.read_gml('BeloHorizonte_DAY.gml')
	Gnull = get_randomized_network(G)

  	

