def runthis():
	fin = open("common.txt")
	String = fin.readlines()
	fin.close()
	
	for i in range(len(String)):
		String[i] = String[i][:-1]
	
	Mapping = {'a': 1, 'b': 2, 'c':3, 'd':4, 'e':5, 'f':6, 'g':7, 'h':8, 'i':9, 'j':10, 'k':11, 'l':12, 'm':13, 'n':14, 'o':15, 'p':16, 'q':17, 'r':18, 's':19, 't':20, 'u':21, 'v':22, 'w':23, 'x':24, 'y':25, 'z':26}
	
	'''
	numericals = []
	for i in range(len(String)):
			numericals.append((String[i], Mapping[String[i][0]], Mapping[String[i][1]], Mapping[String[i][2]]))
	print numericals
	'''
	
	G = nx.Graph()
	for i in range(len(String)):
		for j in range(i+1, len(String)):
			if String[i][0] == String[j][0] and String[i][1] == String[j][1] and String[i][2] != String[j][2] or String[i][0] == String[j][0] and String[i][1] != String[j][1] and String[i][2] == String[j][2] or String[i][0] != String[j][0] and String[i][1] == String[j][1] and String[i][2] == String[j][2]:
				G.add_edge(String[i], String[j])


	fin = open("wordmorph.Mygml", 'w')
	string = pickle.dumps(G)
	fin.write(string)
	fin.close()
	
	AtoB.createRealWorld("wordmorph")
	
	print "Number of words:", len(String)
	print "Drawing Graph..."
	nx.draw(G)
	plt.show()
def runthis():
	fin = open('p2p-Gnutella08.txt','r')
	String = fin.read()
	fin.close()
	ConnectionList = String.rsplit()[29:]
	EdgeList = []
	for i in range(0,len(ConnectionList),2):
		EdgeList.append((int(ConnectionList[i]), int(ConnectionList[i+1])))
	G = nx.Graph()
	G.add_edges_from(EdgeList)
	G = nx.subgraph(G,range(500))
	
	fin = open("gnutella.Mygml", 'w')
	string = pickle.dumps(G)
	fin.write(string)
	fin.close()
	
	AtoB.createRealWorld("gnutella")
import numpy
import math
import AtoB
import matplotlib.pyplot as plt
import random
import networkx as nx
import pdb
import pickle

n = 200
edgeProb = 0.3
degree = 3

# name = "gnutella"

# AtoB.createErdos(n,edgeProb)
# G = nx.read_gpickle("EG_" + str(n) + "_" + str(edgeProb) + ".gpickle")

# AtoB.createScaleFreeNetwork(n, degree)
# G = nx.read_gpickle("SFN_" + str(n) + "_" + str(degree) + ".gpickle")

AtoB.createRealWorld(name)
G = nx.read_gpickle(str(name) + ".gpickle")

# AtoB.simple_query(G)
AtoB.comparison_query(G)