I need help creating a dot file from a string array.
edges =[["Source1" ,"interfaceA" , "high" , "Sink1" , "interfaceB" , "high"],
["Source2" ,"interfaceC" , "high" , "Sink2" , "interfaceD" , "low"]]
This is how I want the data in my dot file to appear :
digraph mydot {
"Source1" -> "Sink1"
[
label=<<font color="green">interfaceA</font>--><font color="green">interfaceB</font>>
];
"Source2" -> "Sink2"
[
label=<<font color="green">interfaceC</font>--><font color="red">interfaceD</font>>
];
}
I have tried using the code below, but it's not giving me the expected output:
let mydot ='digraph mydot { ';
mydot += edges.map(edge => {
let sourceInterfaceColor = "red";
let sinkInterfaceColor = "red";
if (edge[2]=="high")
sourceInterfaceColor ="green";
if(edge[5]=="high")
sinkInterfaceColor ="green";
mydot +=`\
${edge[0]} -> ${edge[3]} \
[ \
label=<<font color= \"${sourceInterfaceColor}\">\"${edge[1]}\"</font>--><font color=\"${sinkInterfaceColor}\">${edge[4]}</font>> \
];`
.stripMargin});
mydot +='}';
How can I modify mydot to correctly generate the digraph data?