-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnecting-nodes.js
55 lines (55 loc) · 2.21 KB
/
connecting-nodes.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
//Connecting Nodes
/*to connect nodes we take two levels at a time ith and (i+1)th then for every node in the ith level
we visit the (i+1)th level and generate nodes from the node of ith level to node of (i+1)th level
iff node in (i+1)th level has all the attributes that ith level node has.*/
for (i = 1; i <= set.length; i++) {
current_breadth = k_combinations(set, i); //ith level
next_breadth = k_combinations(set, i + 1); //(i+1)th level
lenk = current_breadth.length;
j = 1;
for (curnode of current_breadth) { //for every node in ith level
k = 1;
for (nexnode of next_breadth) { //for every node in (i+1)th level
for (curel of curnode) { //for every attribute in the node of ith object
for (nexel of nexnode) { //for every attribute in the node of (i+1)th level
if (curel === nexel) { //if we find nodes where the condition is satisfied we
tempJson.push({ //generate a connection
"data": {
"source": (k + presum + lenk).toString(), // source node id
"target": (j + presum).toString(), //target node id
"weight": 10.0055478187,
"group": "coexp",
"networkId": (iterable).toString(),
"networkGroupId": 18,
"intn": true,
"rIntnId": 2,
"id": "e" + (iterable).toString()
},
"position": {},
"group": "edges",
"removed": false,
"selected": false,
"selectable": true,
"locked": false,
"grabbed": false,
"grabbable": true,
"classes": ""
});
iterable++;
}
}
}
k++;
if (tempJson.length == curnode.length) {
for (a of tempJson) {
dataJson.push(a);
//console.log(a);
break;
}
}
tempJson = [];
}
j++;
}
presum = presum + current_breadth.length;
}