Repository navigation
Expand file tree
/
Copy pathesri.jl
More file actions
41 lines (32 loc) · 1.34 KB
/
Copy pathesri.jl
File metadata and controls
41 lines (32 loc) · 1.34 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
include("extern.jl");
include("functions.jl");
function main(inputfile::String="data/input.csv", outputfile::String="data/output.csv")
arrays_file = first(splitext(inputfile)) * "_arrays.jld2";
# if file with arrays exists, load it with jld2
if isfile(arrays_file)
@info "Restoring working space from file \"$arrays_file\"";
M,A = load(arrays_file, "M", "A");
else
@info "Initializing the market according to input file \"$inputfile\"";
M = initializeMarket(inputfile);
@info "Building sparse adjacency matrices";
A = buildArrays(M);
@info "Saving matrices into file \"$arrays_file\"";
jldsave(arrays_file; M,A);
end
nthreads = Threads.nthreads();
if nthreads > 1
@info "You set $nthreads cores to run the code in parallel. I'm impressed!";
# @info "Calculating ESRI in parallel on $nthreads threads";
esri = ESRI_parallel(M, A);
else
@info "Calculating ESRI sequentially";
esri = ESRI(M, A);
end
@info "Saving the results into file \"$outputfile\"";
saveESRI(M, esri, outputfile);
return esri;
end
# esri = main("real_data/complete_edge_list.csv", "real_data/esri_complete.csv");
# esri = main("data/test_list.csv");
esri = main(ARGS...); # first arg is the input file, second is the output file