Skip to content

Commit 5a71a21

Browse files
committed
netloc_draw: add bandwidth_check color mode
Signed-off-by: Cyril Bordage <[email protected]>
1 parent c55523f commit 5a71a21

File tree

1 file changed

+54
-23
lines changed

1 file changed

+54
-23
lines changed

utils/netloc/draw/netloc_draw.html

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@
187187
el.value = "bandwidth";
188188
selectColors.appendChild(el);
189189
}
190+
{
191+
var el = document.createElement("option");
192+
el.textContent = "bandwidth_check";
193+
el.value = "bandwidth_check";
194+
selectColors.appendChild(el);
195+
}
190196

191197
/* Add elements to selectPartition */
192198
var selectPartition = document.getElementById("selectPartition");
@@ -270,62 +276,86 @@
270276
shownNodes.update({id: n.id, color: normalSwitchColor});
271277
});
272278

273-
if (lastColorMode == "bandwidth") {
279+
if (lastColorMode == "bandwidth" || lastColorMode == "bandwidth_check") {
274280
shownEdges.forEach(function(n) {
275281
shownEdges.update({id: n.id, color: normalEdgeColor});
276282
});
277283
}
278-
}
279-
else if (colorMode == "partition") {
284+
285+
} else if (colorMode == "partition") {
280286
var nodeColors = palette(partitions.length);
281287
shownNodes.forEach(function(n) {
282288
if (n.type == "host") {
283289
var colorIdx = n.part[0];
284290
shownNodes.update({id: n.id, color: {background: nodeColors[colorIdx]}});
285-
}
286-
else
291+
292+
} else
287293
shownNodes.update({id: n.id, color: normalSwitchColor});
288294
});
289295

290-
if (lastColorMode == "bandwidth") {
296+
if (lastColorMode == "bandwidth" || lastColorMode == "bandwidth_check") {
291297
shownEdges.forEach(function(n) {
292298
shownEdges.update({id: n.id, color: normalEdgeColor});
293299
});
294300
}
295-
}
296-
else if (colorMode == "hwloc") {
301+
302+
} else if (colorMode == "hwloc") {
297303
var nodeColors = palette(topos.length);
298304
shownNodes.forEach(function(n) {
299305
if (n.type == "host") {
300306
var colorIdx = n.topo;
301307
if (colorIdx != -1) {
302308
shownNodes.update({id: n.id, color: {background: nodeColors[colorIdx]}});
303309
}
304-
}
305-
else
310+
311+
} else
306312
shownNodes.update({id: n.id, color: normalSwitchColor});
307313
});
308314

309-
if (lastColorMode == "bandwidth") {
315+
if (lastColorMode == "bandwidth" || lastColorMode == "bandwidth_check") {
310316
shownEdges.forEach(function(n) {
311317
shownEdges.update({id: n.id, color: normalEdgeColor});
312318
});
313319
}
314-
}
315-
else if (colorMode == "bandwidth") {
320+
321+
} else if (colorMode == "bandwidth") {
316322
var nodeColors = palette(nodeBandwidthList.length);
317323
shownNodes.forEach(function(n) {
318324
var colorIdx = nodeBandwidthList.indexOf(n.size);
319325
if (colorIdx != -1) {
320326
shownNodes.update({id: n.id, color: {background: nodeColors[colorIdx]}});
321327
}
322328
});
329+
var edgeColors = palette(edgeBandwidthList.length);
330+
shownEdges.forEach(function(n) {
331+
var colorIdx = edgeBandwidthList.indexOf(n.gbits);
332+
if (colorIdx != -1) {
333+
shownEdges.update({id: n.id, color: {color: edgeColors[colorIdx]}});
334+
}
335+
});
323336

324-
var edgeeColors = palette(edgeBandwidthList.length);
337+
} else if (colorMode == "bandwidth_check") {
338+
var edgeColors = palette(edgeBandwidthList.length);
325339
shownEdges.forEach(function(n) {
326340
var colorIdx = edgeBandwidthList.indexOf(n.gbits);
327341
if (colorIdx != -1) {
328-
shownEdges.update({id: n.id, color: {color: edgeeColors[colorIdx]}});
342+
shownEdges.update({id: n.id, color: {color: edgeColors[colorIdx]}});
343+
}
344+
});
345+
346+
shownNodes.forEach(function(n) {
347+
/* Quick check about in bw = out bd */
348+
if (n.edges.length == 1) {
349+
var colorIdx = edgeBandwidthList.indexOf(n.bandwidth);
350+
shownNodes.update({id: n.id, color: {background: edgeColors[colorIdx]}});
351+
352+
} else {
353+
var colorIdx = edgeBandwidthList.indexOf(n.bandwidth/2);
354+
if (colorIdx != -1) {
355+
shownNodes.update({id: n.id, color: {background: edgeColors[colorIdx]}});
356+
} else {
357+
shownNodes.update({id: n.id, color: {background: "black"}});
358+
}
329359
}
330360
});
331361
}
@@ -489,6 +519,7 @@
489519

490520
if (!similarNeighbours) {
491521
similarNeighbours = neighbours;
522+
492523
} else {
493524
similarNeighbours = similarNeighbours.filter(function(n) {
494525
return neighbours.indexOf(n) != -1;
@@ -529,8 +560,8 @@
529560
var field = selectSearch.options[selectSearch.selectedIndex].value;
530561

531562
if (field == "") {
532-
}
533-
else {
563+
564+
} else {
534565
var searchValue = document.getElementById("searchValue");
535566
var value = searchValue.value;
536567
selectNodesAndEdges(field, value);
@@ -554,8 +585,8 @@
554585
// TODO improve
555586
subEdges = new vis.DataSet(edges.get());
556587
shownNodes = new vis.DataSet(subNodes.get());
557-
}
558-
else {
588+
589+
} else {
559590
subEdges = new vis.DataSet(edges.get({filter: function (e) {
560591
return (e.part.indexOf(partition) > -1);
561592
}}));
@@ -573,12 +604,12 @@
573604
e.arrows = {to: true};
574605
}
575606
return true;
576-
}
577-
else if (!subEdges.get(e.reverse)) {
607+
608+
} else if (!subEdges.get(e.reverse)) {
578609
e.arrows = {to: true};
579610
return true;
580-
}
581-
else
611+
612+
} else
582613
return false;
583614
}}));
584615
printWithTime("Edges filtered (keep one way)");

0 commit comments

Comments
 (0)