-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsigma.js
77 lines (70 loc) · 1.18 KB
/
sigma.js
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
// Initialise sigma:
var s = new sigma(
{
renderer: {
container: document.getElementById('sigma-container'),
type: 'canvas'
},
settings: {
edgeLabelSize: 'proportional',
minArrowSize: 12
}
}
);
// Generate a random graph:
var nbNode = 8;
var nbEdge = 13;
var graph = {
nodes: [],
edges: []
};
graph.nodes.push({
id: 1,
x: 80,
y: 300,
size: 8
});
graph.nodes.push({
id: 2,
x: 150,
y: 300,
size: 5
});
graph.nodes.push({
id: 3,
x: 115,
y: 50,
size: 2
});
////////////////////////////////
graph.edges.push({
id: 1,
source: 1,
target: 2,
color: '#000000',
type: 'curvedArrow',
label: 'first'
});
graph.edges.push({
id: 2,
source: 2,
target: 3,
color: '#000000',
type: 'curvedArrow',
label: 'second'
});
graph.edges.push({
id: 3,
source: 1,
target: 3,
color: '#000000',
type: 'curvedArrow',
label: 'third'
});
// load the graph
s.graph.read(graph);
// draw the graph
s.refresh();
// launch force-atlas for 5sec
/*s.startForceAtlas2();
window.setTimeout(function() {s.killForceAtlas2()}, 0);*/