Skip to main content

EdgeMap

Trait EdgeMap 

Source
pub trait EdgeMap<T>: Graph {
    type Emap;

    // Required methods
    fn construct_emap<F>(&self, f: F) -> Self::Emap
       where F: FnMut() -> T;
    fn emap_get<'a>(&self, map: &'a Self::Emap, eid: Self::Label) -> &'a T;
    fn emap_get_mut<'a>(
        &self,
        map: &'a mut Self::Emap,
        eid: Self::Label,
    ) -> &'a mut T;

    // Provided method
    fn emap_set(&self, map: &mut Self::Emap, eid: Self::Label, value: T) { ... }
}

Required Associated Types§

Required Methods§

Source

fn construct_emap<F>(&self, f: F) -> Self::Emap
where F: FnMut() -> T,

Source

fn emap_get<'a>(&self, map: &'a Self::Emap, eid: Self::Label) -> &'a T

Source

fn emap_get_mut<'a>( &self, map: &'a mut Self::Emap, eid: Self::Label, ) -> &'a mut T

Provided Methods§

Source

fn emap_set(&self, map: &mut Self::Emap, eid: Self::Label, value: T)

Examples found in repository?
crates/competitive/src/graph/order.rs (line 57)
45    fn dfs_tree(&self, root: Self::Vertex) -> <Self as EdgeMap<bool>>::Emap
46    where
47        Self: EdgeMap<bool> + VertexMap<bool>,
48    {
49        let mut visited = self.construct_vmap(|| false);
50        let mut used = self.construct_emap(|| false);
51        *self.vmap_get_mut(&mut visited, root) = true;
52        let mut stack = vec![root];
53        while let Some(u) = stack.pop() {
54            for neighbor in self.neighbors(u) {
55                if !self.vmap_get(&visited, neighbor.to) {
56                    *self.vmap_get_mut(&mut visited, neighbor.to) = true;
57                    self.emap_set(&mut used, neighbor.label, true);
58                    stack.push(neighbor.to);
59                }
60            }
61        }
62        used
63    }

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§