Skip to content

Instantly share code, notes, and snippets.

@sangheestyle
Last active August 29, 2015 14:06
Show Gist options
  • Save sangheestyle/ea8687f4d76f6ed31a14 to your computer and use it in GitHub Desktop.
Save sangheestyle/ea8687f4d76f6ed31a14 to your computer and use it in GitHub Desktop.
Run SSSP
#!/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 ..
@sangheestyle
Copy link
Author

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 install wget with homebrew.

PC1: Sanghee's desktop (4 cores, fast)

$ curl "https://gist.githubusercontent.com/sangheestyle/ea8687f4d76f6ed31a14/raw/7f8b1ef188eb2da9a09658a363ff8cf5ea1b41ef/run_sssp.sh" -o "run_sssp.sh"
$ bash run_sssp.sh 0 30

PC2: Sanghee's macbook (8 cores, slow)

$ curl "https://gist.githubusercontent.com/sangheestyle/ea8687f4d76f6ed31a14/raw/7f8b1ef188eb2da9a09658a363ff8cf5ea1b41ef/run_sssp.sh" -o "run_sssp.sh"
$ bash run_sssp.sh 30 50

PC3: Choong-wan's server 1 ()

$ curl "https://gist.githubusercontent.com/sangheestyle/ea8687f4d76f6ed31a14/raw/7f8b1ef188eb2da9a09658a363ff8cf5ea1b41ef/run_sssp.sh" -o "run_sssp.sh"
$ bash run_sssp.sh 50 75

PC4: Choong-wan's server 2()

$ curl "https://gist.githubusercontent.com/sangheestyle/ea8687f4d76f6ed31a14/raw/7f8b1ef188eb2da9a09658a363ff8cf5ea1b41ef/run_sssp.sh" -o "run_sssp.sh"
$ bash run_sssp.sh 75 100

@sangheestyle
Copy link
Author

저는 1번, 2번 두 개 방금 돌렸습니다. - 3시 41분.

@sangheestyle
Copy link
Author

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

@sangheestyle
Copy link
Author

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