Node Functions
move_aside
node CONN.move_aside()
Arguments:
Move the node to the side so that its inputs go to the output
Network Functions
load_file
network CONN.load_file(
file: 'PathBuf',
append: 'bool' = false,
force: 'bool' = false
)
Arguments:
file: 'PathBuf'=> File to load the network connections fromappend: 'bool' = false=> Append the connections in the current networkforce: 'bool' = false=> Force overriding outputs if previous one is present, only valid for override
Load the given file into the network
This replaces the current network with the one loaded from the file.
load_str
network CONN.load_str(
contents: '& str',
append: 'bool' = false,
force: 'bool' = false
)
Arguments:
contents: '& str'=> String containing Network connectionsappend: 'bool' = false=> Append the connections in the current networkforce: 'bool' = false=> Force overriding outputs if previous one is present, only valid for override
Load network from the given string
This replaces the current network with the one loaded from the string.
network load_str("a -> b");
env assert_eq(nodes.NAME, ["b", "a"])
load_edges
network CONN.load_edges(
edges: '& [(String, String)]',
append: 'bool' = false,
force: 'bool' = false
)
Arguments:
edges: '& [(String, String)]'=> String containing Network connectionsappend: 'bool' = false=> Append the connections in the current networkforce: 'bool' = false=> Force overriding outputs if previous one is present
Load the given edges as a network
This replaces the current network with the one loaded from the file.
network load_edges([["a", "b"], ["b", "c"]]);
env assert_eq(nodes.NAME, ["c", "b", "a"])
subset
network CONN.subset(filter: '& [bool]', keep: 'bool' = true)
Arguments:
filter: '& [bool]'=>keep: 'bool' = true=> Keep the selected nodes (false = removes the selected)
Take a subset of network by only including the selected nodes
network load_str("a -> b\n b->c");
nodes[a->b].sth = true;
node[c].sth = false;
network subset(nodes.sth);
env assert_eq(nodes.NAME, ["b", "a"])
save_file
network CONN.save_file(
file: 'PathBuf',
quote_all: 'bool' = true,
graphviz: 'bool' = false
)
Arguments:
file: 'PathBuf'=> Path to the output filequote_all: 'bool' = true=> quote all node names; if false, doesn’t quote valid identifier namesgraphviz: 'bool' = false=> wrap the network into a valid graphviz file
Save the network into the given file
For more control on graphviz file writing, use
save_graphviz from graphviz plugin instead.
subset_from
network CONN.subset_from(new_root: '& str')
Arguments:
new_root: '& str'=>
Take a subset of network by taking the given node as a new outlet
network load_str("a -> b\n b->c\n x -> y");
network subset_from("b")
env assert_eq(nodes.NAME, ["b", "a"])
subset_largest
network CONN.subset_largest(parent: 'Option < String >')
Arguments:
parent: 'Option < String >'=>
Take a subset of network by only including the largest blob of connected nodes
When you load a network that have disconnected nodes, this function allows you to filter out all the nodes except the one belonging to the largest connected network (number of nodes). Alternatively, you can also use ORDER and other logic in the task system to do that.
If your network has a root node, and no parent node is given, then it’ll just keep the network as it is.
network load_str("a -> b\n b->c\n x -> y");
network subset_largest()
env assert_eq(nodes.NAME, ["c", "b", "a"])