ucd-cws / calvin-network-tools

Command line tools for calvin-network-data and calvin-network-app. Includes prm tool for export PRI and DSS files
MIT License
3 stars 5 forks source link

Add digraph to cnf matrix #25

Open qjhart opened 8 years ago

qjhart commented 8 years ago

Here's a simple example, of a digraph. It would be nice if we could add these in with the cnf matrix command, although they do get complicated pretty quickly.

digraph g {
SOURCE -> "INBOUND.2001-08-31"
"INBOUND.2001-08-31" -> "SR_WHI.2001-08-31" [label=203];
"OUTBOUND.2001-08-31" -> SINK;
"SR_WHI.2001-08-31" -> "OUTBOUND.2001-08-31" [label= 1.348958];
"SR_WHI.2001-08-31" -> "OUTBOUND.2001-08-31" [label=5.226399];
"SR_WHI.2001-08-31" -> "OUTBOUND.2001-08-31" [label=202.909302];
SOURCE -> "INBOUND.2001-09-30";
"INBOUND.2001-09-30" -> "SR_WHI.2001-09-30" [label=186.47];
"OUTBOUND.2001-09-30" -> SINK;
"SR_WHI.2001-09-30" -> "OUTBOUND.2001-09-30" [label=0.317708];
"SR_WHI.2001-09-30" -> "OUTBOUND.2001-09-30" [label=8.92557];
"SR_WHI.2001-09-30" -> "OUTBOUND.2001-09-30" [label=176.010254];
SOURCE -> INITIAL;
INITIAL -> "SR_WHI.2001-08-31" [label=179.703156];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="10 10"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 17.5"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 70.484"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 75.089"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 8.427"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 19.5"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 19.5"];
"SR_WHI.2001-08-31" -> "SR_WHI.2001-09-30" [label="0 19.5"];
FINAL -> SINK;
"SR_WHI.2001-09-30" -> FINAL [label=173.271866];
SOURCE -> "INFLOW.2001-08-31" ;
"INFLOW.2001-08-31" -> "SR_WHI.2001-08-31" [label=4.39405];
SOURCE -> "INFLOW.2001-09-30" ;
"INFLOW.2001-09-30" -> "SR_WHI.2001-09-30" [label=4.363636];
}
jrmerz commented 8 years ago

First pass at this library looks semi promising https://github.com/glejeune/node-graphviz. Hasn't been worked on in awhile, but seems to work. Obviously requires graphviz for png output.

jrmerz commented 8 years ago

updates for args here: 600cf220b0c82e02ed3a146fa0ad17060bbbdd88

@qjhart Couple things. I have updated the matrix commands arguments. Changes and reasons below:

Both -f dot and -f png are implemented. Pull and npm install. The png creation requires graphviz to be in your path.

jrmerz commented 8 years ago

For the graph output, I'm not sure which values you want on the link labels. Currently it's [k]:[cost]