-
Notifications
You must be signed in to change notification settings - Fork 22
/
demo.html
157 lines (135 loc) · 3.1 KB
/
demo.html
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html>
<meta charset="utf-8">
<script src="third_party/sigma.js/build/sigma.min.js"></script>
<script src="third_party/sigma.js/build/plugins/sigma.plugins.animate.min.js"></script>
<script src="GPGPUtility.js"></script>
<script src="sigma.layout.fruchtermanReingold.js"></script>
<script src="sigma.layout.paragraphl.js"></script>
<script src="data/grqc_auto.js"></script>
<style>
#webgl {
top: 20px;
bottom: 0;
left: 50px;
right: 0;
color: #000;
background: #fff;
position: absolute;
}
#layout {
top: 0;
left: 0;
position: fixed;
}
.label {
position: absolute;
top: 10px;
left: 10px;
z-index: 1;
font-family: sans-serif;
}
#MaxTime {
left: 0px;
top: 20px;
position: fixed;
}
#MinTime {
left: 0px;
top: 40px;
position: fixed;
}
#AvgTime {
left : 0px;
top: 60px;
position : fixed;
}
</style>
<div id="container">
<div id="webgl">
<!--<button id="layout" type="button">Layout</button>-->
<p id="MaxTime"></p>
<p id="MinTime"></p>
<p id="AvgTime"></p>
</div>
</div>
<script>
var duration = 0.0;
var min_val = 0.0;
var max_val = 0.0;
var sum_val = 0.0;
// Bind all events:
var start_time;
var func = function(event) {
var now = performance.now();
console.log(event.type + ' ' + now);
if (event.type == 'start') {
start_time = now;
}
else {
var end_time = now;
duration = end_time - start_time;
if (iteration === 0) {
min_val = duration;
max_val = duration;
sum_val = duration;
} else {
min_val = Math.min(min_val, duration);
max_val = Math.max(max_val, duration);
sum_val += duration;
}
console.log(duration);
}
};
var iteration;
var loop = 1;
for (iteration = 0; iteration < loop; iteration++) {
console.log(iteration);
var s = new sigma();
var cam = s.addCamera();
// Initialize two distinct renderers, each with its own settings:
s.addRenderer({
container: document.getElementById('webgl'),
type: 'webgl',
camera: cam,
settings: {
defaultLabelColor: '#000',
defaultNodeColor: '#666',
defaultEdgeColor: '#999',
edgeColor: 'default',
drawLabels: false
}
});
s.refresh();
graph.nodes.map(function(d){
s.graph.addNode({
id: d.id,
label: 'Node ' + d.id,
x: Math.random(),
y: Math.random(),
// x: d.id % 97,
// y: d.id % 31,
size: 0
});
})
graph.links.map(function(d, t) {
s.graph.addEdge({
id: 'e' + t,
source: d.source,
target: d.target,
size: 1
});
})
var config = {
iterations : 100,
};
// Choose one of the layout implementations
// var layout = sigma.layouts.fruchtermanReingold;
var layout = sigma.layouts.paragraphl;
var listener = layout.configure(s, config);
listener.bind('start stop', func);
layout.start(s);
}
document.getElementById('MaxTime').innerText = 'Max: ' + max_val + ' ms';
document.getElementById('MinTime').innerText = 'Min: ' + min_val + ' ms';
document.getElementById('AvgTime').innerText = 'Avg: ' + sum_val / loop + ' ms';
</script>