-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-top-centrality-table.jl
More file actions
41 lines (35 loc) · 1.31 KB
/
make-top-centrality-table.jl
File metadata and controls
41 lines (35 loc) · 1.31 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
function make_centrality_table(centralities,labels; number_of_top_nodes = 10)
top_labels_by_centrality = Dict()
for (i,maps) in enumerate(keys(centralities))
x = centralities[maps]["x"]
xid = sortperm(vec(x),rev=true)
xx = x[xid]
top_nodes_by_centrality = xid[1:number_of_top_nodes]
top_labels_by_centrality[maps] = labels[top_nodes_by_centrality]
end
cc = String(['c' for _ in 1 : length(keys(centralities))])
println("""\\begin{tabular}{$cc}""")
println(raw"""\toprule""")
for (j,map) in enumerate(keys(centralities))
mapname = uppercasefirst(map)
if j < length(keys(centralities))
print("""\\textit{$mapname} & """)
else
println("""\\textit{$mapname} \\\\""")
end
end
println(raw"""\midrule""")
for i in 1:number_of_top_nodes
for (j,map) in enumerate(keys(centralities))
nodename = uppercasefirst(replace(top_labels_by_centrality[map][i], "-"=>" "))
if j < length(keys(centralities))
print("""$nodename & """)
else
println("""$nodename \\\\""")
end
end
end
println(raw"""\bottomrule""")
println(raw"""\end{tabular}""")
return top_labels_by_centrality
end