Network Function
Network function runs on the network as a whole. It takes arguments and keyword arguments. Few network functions we have been using throughout the examples are load_file, load_str and cairo.table:
network load_file("./data/mississippi.net")
network command("mkdir -p output")
nodes.title = str_replace(NAME, "-", " ");
network cairo.table(
"Index => {INDEX}\n<Name => {NAME}\n",
"./output/network-mississippi-sdf.svg"
)
Results:
For example following network function takes file path as input to save the network in graphviz format:
save_gv(
outfile [PathBuf],
name [String] = "network",
global_attrs [String] = "",
node_attr [Option < Template >],
edge_attr [Option < Template >]
)
Note that, if the arguments have default values, or are optional, then you do not need to provide them.
For example, you can simply call the above function like this.
network load_file("./data/mississippi.net")
network save_gv("./output/test.gv")
network clip()
# the path link are relative to /src
network echo("./output/test.gv")
Results:
digraph network {
"red" -> "lower-mississippi"
"arkansas" -> "lower-mississippi"
"missouri" -> "lower-mississippi"
"upper-mississippi" -> "lower-mississippi"
"ohio" -> "lower-mississippi"
"tenessee" -> "ohio"
}
With extra commands you can also convert it into an image
network load_file("./data/mississippi.net")
network save_gv("./output/test.gv")
network command("dot -Tsvg ./output/test.gv -o ./output/test.svg")
network clip()
# the link path needs to be relative to this file
network echo("../output/test.svg")
Results:
Playground: HTML only
Most network functions are for IO operations so there are very few you can try out to get values, but here are some examples. Note that you can get the results of these network functions using task keywords nodesmap and roots
network load_str("
123 -> something
another -> thing
")
net.nodemap("NAME") # nodesmap.NAME
net.net_roots() # roots.NAME