-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreal_hypergraph_data.jl
More file actions
125 lines (102 loc) · 3.45 KB
/
real_hypergraph_data.jl
File metadata and controls
125 lines (102 loc) · 3.45 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using LinearAlgebra
using SparseArrays
using StatsBase
include("centrality_tools.jl")
include("real_data_tools.jl")
# choose dataset :
dataset_name = "stackoverflow"
name_title = "Math stackexchange co-tags"
# dataset_name = "walmart"
# name_title = "Walmart trips"
if dataset_name == "walmart"
B,w,labels,names,edges = read_walmart_data();
elseif dataset_name == "stackoverflow"
B,w,edges = read_tags_data("tags-math-sx");
labels = read_tags_data_node_labels("tags-math-sx")
end
n,m = size(B)
mappings = Dict("linear" => (x -> x, x -> x, x -> x, x -> x),
"log-exp" => (x -> x, x -> x.^(1/10), x -> log.(x), x -> exp.(x)),
"max" => (x -> x, x -> x.^(1/5), x -> x.^15, x -> x.^(1/15))
)
centralities = Dict();
for maps in mappings
@show maps[1]
x,y = compute_centrality(B,maps[2],edge_weights = w, maxiter=100);
centralities[maps[1]] = Dict("x"=>x, "y"=>y)
end
include("make-top-centrality-table.jl")
top_labels_by_centrality = make_centrality_table(centralities,labels, number_of_top_nodes = 10)
ftlabels = 15
ftticks = 12
fttitle = 18
# node scatter plot =============================================================
figure()
suptitle("$name_title node centrality", fontsize=fttitle)
subplot(131)
x = centralities["linear"]["x"];
xx = centralities["log-exp"]["x"];
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("linear",fontsize=ftlabels)
ylabel("log-exp",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
subplot(132)
x = centralities["max"]["x"];
xx = centralities["log-exp"]["x"];
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("max",fontsize=ftlabels)
ylabel("log-exp",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
subplot(133)
x = centralities["linear"]["x"];
xx = centralities["max"]["x"];
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("linear",fontsize=ftlabels)
ylabel("max",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
# edge scatter plot =============================================================
figure()
suptitle("$name_title edge centrality", fontsize=fttitle)
subplot(131)
x = centralities["linear"]["y"]; x = x[1:5000]
xx = centralities["log-exp"]["y"]; xx = xx[1:5000]
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("linear",fontsize=ftlabels)
ylabel("log-exp",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
subplot(132)
x = centralities["max"]["y"]; x = x[1:5000]
xx = centralities["log-exp"]["y"]; xx = xx[1:5000]
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("max",fontsize=ftlabels)
ylabel("log-exp",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
subplot(133)
x = centralities["linear"]["y"]; x = x[1:5000]
xx = centralities["max"]["y"]; xx = xx[1:5000]
plot(x./maximum(x),xx./maximum(xx), "o")
xlabel("linear",fontsize=ftlabels)
ylabel("max",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
# Scatterplot edge centrality vs edge weights ==============================
w = vec(diag(W)) #edge weights
δ = vec(sum(B,dims=1)) #edge degree
f = figure()
suptitle("$name_title edge centrality vs edge weights", fontsize=fttitle)
for (i,maps) in enumerate(keys(mappings))
y = centralities[maps]["y"]
subplot(1,length(keys(mappings)),i)
plot(y./maximum(y), w./maximum(w),"o")
if i == 1
ylabel("edge weight",fontsize=ftlabels)
end
xlabel("$maps edge centrality",fontsize=ftlabels)
xticks(fontsize=ftticks)
yticks(fontsize=ftticks)
end