Implement basic graphviz networkmap. #252

This commit is contained in:
Koenkk
2018-08-28 22:07:57 +02:00
parent 2a520b0e81
commit b2a27dd64a
+13
View File
@@ -14,6 +14,7 @@ class NetworkMap {
// Set supported formats
this.supportedFormats = {
'raw': this.raw,
'graphviz': this.graphviz,
};
}
@@ -33,6 +34,18 @@ class NetworkMap {
raw(topology) {
return JSON.stringify(topology);
}
graphviz(topology) {
let text = 'digraph G {\n';
topology.forEach((item) => {
text += ` "${item.ieeeAddr}" [label="${item.ieeeAddr} (${item.status})"];\n`;
text += ` "${item.ieeeAddr}" -> "${item.parent}" [label="${item.lqi}"]\n`;
});
text += '}';
return text;
}
}
module.exports = NetworkMap;