Last active
August 29, 2015 14:06
-
-
Save sangheestyle/ea8687f4d76f6ed31a14 to your computer and use it in GitHub Desktop.
Run SSSP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir sssp | |
cd sssp | |
curl "https://dl.dropboxusercontent.com/u/7571776/facebook100_txt_only.zip" -o "facebook100_txt_only.zip" | |
unzip facebook100_txt_only.zip | |
curl https://gist.githubusercontent.com/sangheestyle/6335b209b4779dddc5ac/raw/47a803d6ccfa727efb80d5c32f5e7361d32c861a/ps16c.py > ps16c.py | |
mkdir out | |
python ps16c.py facebook100txt $1 $2 | |
cd .. |
저는 1번, 2번 두 개 방금 돌렸습니다. - 3시 41분.
You can check your result in IPython
In [8]: import json
In [9]: sssp = json.load(open("Middlebury45.txt.geo.json", "r"))
In [10]: sum(sssp) / len(sssp)
Out[10]: 2
Snippet
a = {}
a["file1"] = {"sum":10, "max": 20, "number": 30}
a["file2"] = {"sum":10, "max": 20, "number": 30}
import json
json.dump(a, open("test.json", "w"))
json.load(open("test.json", "r"))
r = json.load(open("test.json", "r"))
for item in r:
print r[item]["max"]
So
import json
from os import listdir
from os.path import isfile, join, basename
def get_file_paths(root):
file_paths = []
for f in listdir(root):
if isfile((join(root, f))):
file_paths.append(join(root, f))
return file_paths
def get_summary(root):
summary = {}
for path in get_file_paths(root):
sp = json.load(open(path, 'r'))
sum = sum(sp)
len = len(sp)
max = max(sp)
summary[basename(path)] = {"number": len, "sum": sum, "max": max, "avg": sum/len}
return summary
def to_json(data, file_name):
json.dump(data, open(file_name, "w"))
if __name__=="__main__":
root = sys.argv[1]
output_file_name = sys.argv[2]
summary = get_summary(root)
to_json(summary, output_file_name)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We will assign jobs like following! Just share out folder after done.
p.s. If you don't have
wget
in your mac, you may need to installwget
with homebrew.PC1: Sanghee's desktop (4 cores, fast)
PC2: Sanghee's macbook (8 cores, slow)
PC3: Choong-wan's server 1 ()
PC4: Choong-wan's server 2()