-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcompute_social_agony.py
33 lines (27 loc) · 1.11 KB
/
compute_social_agony.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
from datetime import datetime
import os.path
from helper_funs import dir_tail_name
def compute_social_agony_script(graph_file,output,agony_path = "agony/agony "):
command = agony_path + graph_file + " " + output
from helper_funs import run_command
print("running command: %s" % command)
start = datetime.now()
run_command(command)
end = datetime.now()
time_used = end - start
print("time used in computing social agony: %0.4f s" % (time_used.seconds))
print("====compute agony done=====")
def compute_social_agony(graph_file,agony_path = "agony/agony "):
dir_name,tail = dir_tail_name(graph_file)
output = os.path.join(dir_name,tail.split(".")[0] + "_socialagony.txt")
compute_social_agony_script(graph_file,output,agony_path = agony_path)
from file_io import read_dict_from_file
agony_score = read_dict_from_file(output)
return agony_score
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-g","--graph_file",default= " ", help = "input graph file name (edges list)")
args = parser.parse_args()
graph_file = args.graph_file
compute_social_agony(graph_file)