Пример #1
0
start = 100
end = 401
step = 20

x = []
oneWayRandom = []
twoWayRandom = []
oneWayAdamic = []
twoWayAdamic = []

for n in range(start, end, step):
	AtoB.createScaleFreeNetwork(n, degree)	
	G = nx.read_gpickle("SFN_" + str(n) + "_" + str(degree) + ".gpickle")
	#AtoB.createErdos(n,edgeProb)
	#G = nx.read_gpickle("EG_" + str(n) + "_" + str(edgeProb) + ".gpickle")
	result = AtoB.comparison_query(G)
	oneWayRandom.append(result[0])
	twoWayRandom.append(result[1])
	oneWayAdamic.append(result[2])
	twoWayAdamic.append(result[3])
	x.append(n)

plt.plot(x, oneWayRandom)
plt.plot(x, twoWayRandom)
plt.plot(x, oneWayAdamic)
plt.plot(x, twoWayAdamic)
plt.xlabel("Number of Nodes")
plt.ylabel("Average of (length of approx path / length of shortest path) over nC2 pairs")
#plt.title("Average time taken to compute the approximate shortest path for all the nC2 pairs")
plt.show()
Пример #2
0
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)
Пример #3
0
import numpy
import math
import AtoB
import matplotlib.pyplot as plt
import random
import networkx as nx
import pdb
import pickle

name = "gnutella"
trials = 100

G = nx.read_gpickle(str(name) + ".gpickle")
result = AtoB.comparison_query(G, trials)

ind = numpy.arange(4)
width = 0.15
plt.bar(ind, (result[0], result[1], result[2], result[3]), width)
plt.xticks(ind+width/2., ('One-way Random walk', 'Two-way Random walk', 'One-way Adamic walk', 'Two-way Adamic walk') )

plt.xlabel("Number of Nodes")
plt.ylabel("Average of (length of approx path / length of shortest path) over nC2 pairs")
#plt.title("Average time taken to compute the approximate shortest path for all the nC2 pairs")
plt.show()

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

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