-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneuron_graph.js
65 lines (56 loc) · 1.26 KB
/
neuron_graph.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
function graph(neurons, connections) {
x = 0
y = 0
data = {
nodes: [],
edges: []
}
neurons.forEach((neuron) => {
data.nodes.push(
{
id: neuron.id,
label: neuron.id,
x: Math.random(),
y: Math.random(),
size: 3
}
)
x += 1;
y += 1;
});
e = 1;
connections.forEach((connection) => {
data.edges.push(
{
id: e,
source: connection[0],
target: connection[1],
size: 3,
type: 'arrow'
}
)
e += 1;
});
s = new sigma(
{
graph: data,
renderer: {
container: 'graph-container',
type: 'canvas'
},
settings: {
defaultNodeColor: '#ec5148',
autoRescale: ['nodePosition', 'nodeSize'],
edgeLabelSize: 'proportional'
}
}
);
s.bind('clickNode', (e) => {
node_id = e.data.node.id;
neurons[node_id].spike();
});
s.bind('rightClick', (e) => {
node_id = e.data.node.id;
});
return s;
}