Statistics
| Branch: | Revision:

root / globecomm / main.py @ bd3d6dca

History | View | Annotate | Download (807 Bytes)

1
from os import listdir
2
from os.path import isfile, join, splitext, basename
3
import sys
4
import networkx as nx
5

    
6
sys.path.append("heuristic_bc/")
7
from heuristic_betweenness_centrality import HeuristicBetweennessCentrality as HBC
8

    
9
from pdb import set_trace as debugger
10

    
11

    
12
GRAPH_DIRS='/home/quynh/Thesis/quynhnguyen-ms/experiment_input_graphs/CNGraphs/snapshots'
13
def get_all_files_from_dir(dir):
14
    return [join(dir, f) for f in listdir(dir) if isfile(join(dir, f))]
15

    
16

    
17
if __name__ == '__main__':
18
    onlyfiles = get_all_files_from_dir(GRAPH_DIRS)
19

    
20
    for in_filepath in onlyfiles:
21
        filename = splitext(basename(in_filepath))[0]
22
        graph = nx.read_weighted_edgelist(in_filepath)
23
        hbc = HBC(graph)
24
        out_filepath = join('output/', filename + '.hbcout')
25
        hbc.write(out_filepath)
26

    
27

    
28