-
Notifications
You must be signed in to change notification settings - Fork 4
/
EXP4-SynthRunTimeAnalysis.py
63 lines (50 loc) · 2.06 KB
/
EXP4-SynthRunTimeAnalysis.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Writen by Stephen Bonner 2016
#This file is part of GraphFingerprintComparison.
#GraphFingerprintComparison is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#GraphFingerprintComparison is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with GraphFingerprintComparison. If not, see <http://www.gnu.org/licenses/>.
from graph_tool.all import *
import os, csv, time, datetime, sys
import GFP
import NetSimilie
from pylab import *
from tabulate import tabulate
def barabasiNetGen(size):
g = price_network(size, m = 2, directed = False)
return g
# Code for the experiment measuring the rumtime of the code
if __name__ == "__main__":
finalR = []
row = ["GraphName", "GFPSingle", "GFPGlobal", "GFPTotal", "NetSimile"]
finalR.append(row)
resultFile = open('EXP4Results.txt', 'w')
graphSizes = [10, 100, 1000, 10000, 100000, 1000000, 10000000]
graphs = []
count = 0
for i in graphSizes:
g = barabasiNetGen(i)
graphs.append(g)
for g in graphs:
for i in range(0, 5):
print graphSizes[count]
GFPSingle = time.time()
GFP.GFPSingleFingerprint(g)
GFPSingle = time.time() - GFPSingle
GFPGlobal = time.time()
GFP.globalFeatureExtraction(g)
GFPGlobal = time.time() - GFPGlobal
print GFPSingle, GFPGlobal
sys.stdout.flush()
res = [graphSizes[count], GFPSingle, GFPGlobal, (GFPSingle+GFPGlobal)]
finalR.append(res)
resultFile.writelines(tabulate(finalR, headers="firstrow", tablefmt="grid"))
resultFile.flush()
count = count + 1
resultFile.close()