-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetStatistics.py
More file actions
89 lines (74 loc) · 2.37 KB
/
Copy pathgetStatistics.py
File metadata and controls
89 lines (74 loc) · 2.37 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# FILE: getStatistics.py
# AUTHORS: Marina Elmore, Jennifer Hu
# AHPCRC Summmer Institute 2014
# -------------------------------------------------
# This program accesses the text files created by Delite to compile the statistics
# for the efficacy of the Louvain Algorithm. It returns a textfile that is then accessed
# by the display graph algorithm to populate the "Statistics Textbox"
#
import sys, os,commands
def main():
run("twitter/twitter_1.txt")
def return_label(input):
print input
label = ""
if input == "facebook":
label = "Facebook Social Network"
elif input == "higgs":
label = "Higgs Boson Tweets"
elif input == "oregon":
label = "Oregon Route Views"
elif input == "twitter":
label = "Twitter Social Network"
elif input == "hepPh":
label = "Physics Phenomenology"
elif input == "hepTh":
label = "Physics Theory Citations"
elif input == "wiki":
label = "Wikipedia Vote Network"
elif input == "gnutella":
label = "Gnutella Network"
return label
def run(me=""):
#Go to correct directory
os.chdir('/home/armysummer/tangelo_html/community_detection/')
#Get Paths
path = 'input/' + me;
dataset, input_file = me.split('/')
print dataset
label = return_label(dataset)
print label
level = int(input_file[len(input_file)-5:len(input_file)-4]) + 1
stat_file = "input/" + dataset + '/' + dataset + "_stat.txt"
#Open Files
final_stats = open('stats.txt', 'w')
initial_stats = open(stat_file, 'r')
curr_stats = open(path, 'r')
#Add Title
title = str(label + ":<br>Level " + str(level)).title()
final_stats.write("<p><b>" + title + "</b><p>")
final_stats.write("<p><b>Initial Statistics:</b>")
#Add Initial Stats
line = initial_stats.next()
nodes, edges = line.split(' Number')
final_stats.write('<br>' + nodes)
final_stats.write('<br>Number' + edges + '</p>')
final_stats.write('\n')
#Add Iteration Stats
final_stats.write("<p><b>Current Statistics:</b>")
line = curr_stats.next()
nodes, edges = line.split(' Number')
final_stats.write('<br>' + nodes)
final_stats.write('<br>Number' + edges)
#Add modularity Stats
line = curr_stats.next()
old_mod, new_mod = line.split(' New')
final_stats.write('<br>' + old_mod)
final_stats.write('<br>New' + new_mod + "</p>")
#Close files
final_stats.close()
initial_stats.close()
curr_stats.close()
return me
if __name__ == "__main__":
main()