pub struct DirectedGraph<T> { /* private fields */ }Expand description
A simple directed graph structure for using in the SDDP algorithm, to make the temporal decomposition of the problem, store the power system configurations, the built policies and simulation results.
Implementations§
Source§impl<T> DirectedGraph<T>
impl<T> DirectedGraph<T>
pub fn new() -> Self
Sourcepub fn add_node(&mut self, data: T) -> Result<usize, GraphBuildingError>
pub fn add_node(&mut self, data: T) -> Result<usize, GraphBuildingError>
Adds a new node to the node collection. Since the graph is only
built at the beginning of the algorithm, the push call is not
expensive for the total time
Sourcepub fn add_edge(
&mut self,
source_id: usize,
target_id: usize,
) -> Result<(), GraphBuildingError>
pub fn add_edge( &mut self, source_id: usize, target_id: usize, ) -> Result<(), GraphBuildingError>
Adds a new edge to the adjancency maps. Since the graph is only
built at the beginning of the algorithm, the push call is not
expensive for the total time
pub fn get_node(&self, id: usize) -> Option<&Node<T>>
pub fn get_node_id_with<F>(&self, f: F) -> Option<usize>
pub fn get_all_node_ids_with<F>(&self, f: F) -> Vec<usize>
pub fn get_node_mut(&mut self, id: usize) -> Option<&mut Node<T>>
pub fn get_children(&self, id: usize) -> Option<&[usize]>
pub fn get_parents(&self, id: usize) -> Option<&[usize]>
pub fn get_bfs(&self, root_id: usize, reverse: bool) -> Vec<usize>
pub fn node_count(&self) -> usize
pub fn is_root(&self, id: usize) -> bool
pub fn is_leaf(&self, id: usize) -> bool
Source§impl<T> DirectedGraph<T>
impl<T> DirectedGraph<T>
pub fn map_topology_with_default<U: Default>(&self) -> DirectedGraph<U>
pub fn map_topology_with<U, F>(&self, f: F) -> DirectedGraph<U>
Auto Trait Implementations§
impl<T> Freeze for DirectedGraph<T>
impl<T> RefUnwindSafe for DirectedGraph<T>where
T: RefUnwindSafe,
impl<T> Send for DirectedGraph<T>where
T: Send,
impl<T> Sync for DirectedGraph<T>where
T: Sync,
impl<T> Unpin for DirectedGraph<T>where
T: Unpin,
impl<T> UnwindSafe for DirectedGraph<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more