pub struct Network { /* private fields */ }
Expand description
Network is a collection of Nodes, with Connection information. The
connection information is saved in the nodes itself (inputs
and
output
variables), but they are assigned from the network.
The nadi system (lit, river system), is designed for the connections between points along a river. Out of different types of river networks possible, it can only handle non-branching tributaries system, where each point can have zero to multiple inputs, but can only have one output. Overall the system should have a single output point. There can be branches in the river itself in the physical sense as long as they converse before the next point of interests. There cannot be node points that have more than one path to reach another node in the representative system.
Here is an example network file,
cannelton -> newburgh
newburgh -> evansville
evansville -> jt-myers
jt-myers -> old-shawneetown
old-shawneetown -> golconda
markland -> mcalpine
golconda -> smithland
The basic form of network file can contain a connection per line. The program also supports the connection import from the DOT format (graphviz package). Network file without any connection format can be written as a node per line, but those network can only call sequential functions, and not input dependent ones.
Depending on the use cases, it can probably be applied to other systems that are similar to a river system. Or even without the connection information, the functions that are independent to each other can be run in sequential order.
Implementations§
source§impl Network
impl Network
pub fn new() -> Self
pub fn nodes_count(&self) -> usize
pub fn node(&self, index: usize) -> Option<&Node>
pub fn nodes(&self) -> impl Iterator<Item = &Node>
pub fn nodes_rev(&self) -> impl Iterator<Item = &Node>
pub fn output(&self) -> Option<&Node>
pub fn contains(&self, node: &Node) -> bool
pub fn contains_name(&self, node: &str) -> bool
pub fn insert_node(&mut self, node: Node)
pub fn insert_node_by_name(&mut self, name: String)
pub fn node_by_name(&self, name: &str) -> Option<&Node>
pub fn get_or_insert_node_by_name(&mut self, name: &str) -> &Node
pub fn from_file<P: AsRef<Path>>(filename: P) -> Result<Self>
pub fn load_attrs<P: AsRef<Path>>(&mut self, attr_dir: P) -> Result<()>
pub fn from_dot<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn reorder(&mut self)
sourcepub fn set_levels(&mut self)
pub fn set_levels(&mut self)
sets the levels for the nodes, 0 means it’s the main branch and increasing number is for tributories level