Network

Struct Network 

Source
pub struct Network<N: NodeType, L: Copy + Debug + Send + Sized, EXTID: Copy + Debug + Send + Sized + Ord = ExternalId> { /* private fields */ }
Expand description

A directed, acylic network.

Implementations§

Source§

impl<N: NodeType, L: Copy + Debug + Send + Sized, EXTID: Copy + Debug + Send + Sized + Ord> Network<N, L, EXTID>

Source

pub fn new() -> Network<N, L, EXTID>

Source

pub fn node_count(&self) -> usize

Source

pub fn node(&self, node_idx: NodeIndex) -> &Node<N, EXTID>

Source

pub fn node_mut(&mut self, node_idx: NodeIndex) -> &mut Node<N, EXTID>

Source

pub fn nodes(&self) -> &[Node<N, EXTID>]

Source

pub fn each_node_with_index<F>(&self, f: F)
where F: FnMut(&Node<N, EXTID>, NodeIndex),

§Complexity

O(number of links)

§Complexity

O(number of links)

§Complexity

O(1)

Removes all outgoing links of node node_idx.

XXX: This can be optimized.

§Complexity

O(k), where k is the number of edges of node_idx.

Removes all incoming links to node node_idx.

XXX: This can be optimized.

Removes all links to and from node node_idx.

Source

pub fn remove_node(&mut self, node_idx: NodeIndex)

Remove the node with index node_idx including all incoming and outgoing links.

Moves the last node in the nodes array into the empty place and rewires all links. As such, this is a quite heavy operation!

§Danger!

The external NodeIndex of the last node is changed!

§Complexity

Worst case O(e), where e is the total number of edges in the graph.

Source

pub fn add_node(&mut self, node_type: N, external_node_id: EXTID) -> NodeIndex

Adds a new node to the network with type node_type and the associated id external_node_id. The external_node_id is stored in the node and can be retrieved later on.

Returns a random link between two unconnected nodes, which would not introduce a cycle. Return None is no such exists.

Returns true if the introduction of this directed link would lead towards a cycle.

Remove the link at index link_index.

Remove the first link that matches source_node_idx and target_node_idx. XXX

Trait Implementations§

Source§

impl<N: Clone + NodeType, L: Clone + Copy + Debug + Send + Sized, EXTID: Clone + Copy + Debug + Send + Sized + Ord> Clone for Network<N, L, EXTID>

Source§

fn clone(&self) -> Network<N, L, EXTID>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N: Debug + NodeType, L: Debug + Copy + Debug + Send + Sized, EXTID: Debug + Copy + Debug + Send + Sized + Ord> Debug for Network<N, L, EXTID>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<N, L, EXTID> Freeze for Network<N, L, EXTID>

§

impl<N, L, EXTID> RefUnwindSafe for Network<N, L, EXTID>

§

impl<N, L, EXTID> Send for Network<N, L, EXTID>

§

impl<N, L, EXTID> Sync for Network<N, L, EXTID>
where N: Sync, EXTID: Sync, L: Sync,

§

impl<N, L, EXTID> Unpin for Network<N, L, EXTID>
where N: Unpin, EXTID: Unpin, L: Unpin,

§

impl<N, L, EXTID> UnwindSafe for Network<N, L, EXTID>
where N: UnwindSafe, EXTID: UnwindSafe, L: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.