Struct nadi_core::network::Network

source ·
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

source

pub fn new() -> Self

source

pub fn nodes_count(&self) -> usize

source

pub fn node(&self, index: usize) -> Option<&Node>

source

pub fn nodes(&self) -> impl Iterator<Item = &Node>

source

pub fn nodes_rev(&self) -> impl Iterator<Item = &Node>

source

pub fn output(&self) -> Option<&Node>

source

pub fn contains(&self, node: &Node) -> bool

source

pub fn contains_name(&self, node: &str) -> bool

source

pub fn insert_node(&mut self, node: Node)

source

pub fn insert_node_by_name(&mut self, name: String)

source

pub fn node_by_name(&self, name: &str) -> Option<&Node>

source

pub fn get_or_insert_node_by_name(&mut self, name: &str) -> &Node

source

pub fn from_file<P: AsRef<Path>>(filename: P) -> Result<Self>

source

pub fn load_attrs<P: AsRef<Path>>(&mut self, attr_dir: P) -> Result<()>

source

pub fn from_dot<P: AsRef<Path>>(path: P) -> Result<Self>

source

pub fn reorder(&mut self)

source

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

source

pub fn calc_order(&mut self)

source

pub fn print(&self)

Trait Implementations§

source§

impl Default for Network

source§

fn default() -> Network

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Network

§

impl !RefUnwindSafe for Network

§

impl !Send for Network

§

impl !Sync for Network

§

impl Unpin for Network

§

impl !UnwindSafe for Network

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.