Skip to main content

AdjacencyListGraph

Struct AdjacencyListGraph 

Source
pub struct AdjacencyListGraph {
    pub vsize: usize,
    pub esize: usize,
    pub graph: Vec<Vec<Neighbor<usize, usize>>>,
}

Fields§

§vsize: usize§esize: usize§graph: Vec<Vec<Neighbor<usize, usize>>>

Implementations§

Source§

impl AdjacencyListGraph

Source

pub fn new(vsize: usize) -> AdjacencyListGraph

Examples found in repository?
crates/competitive/src/graph/adjacency_list.rs (line 123)
122    fn mscan<I: ScanSource>(self, iter: &mut I) -> Option<Self::Output> {
123        let mut graph = AdjacencyListGraph::new(self.vsize);
124        let mut rest = Vec::with_capacity(self.esize);
125        for _ in 0..self.esize {
126            let (from, to) = (U::scan(iter)?, U::scan(iter)?);
127            if self.directed {
128                graph.add_edge(from, to);
129            } else {
130                graph.add_undirected_edge(from, to);
131            }
132            rest.push(T::scan(iter)?);
133        }
134        Some((graph, rest))
135    }
Source

pub fn add_edge(&mut self, from: usize, to: usize)

Examples found in repository?
crates/competitive/src/graph/adjacency_list.rs (line 128)
122    fn mscan<I: ScanSource>(self, iter: &mut I) -> Option<Self::Output> {
123        let mut graph = AdjacencyListGraph::new(self.vsize);
124        let mut rest = Vec::with_capacity(self.esize);
125        for _ in 0..self.esize {
126            let (from, to) = (U::scan(iter)?, U::scan(iter)?);
127            if self.directed {
128                graph.add_edge(from, to);
129            } else {
130                graph.add_undirected_edge(from, to);
131            }
132            rest.push(T::scan(iter)?);
133        }
134        Some((graph, rest))
135    }
Source

pub fn add_undirected_edge(&mut self, u: usize, v: usize)

Examples found in repository?
crates/competitive/src/graph/adjacency_list.rs (line 130)
122    fn mscan<I: ScanSource>(self, iter: &mut I) -> Option<Self::Output> {
123        let mut graph = AdjacencyListGraph::new(self.vsize);
124        let mut rest = Vec::with_capacity(self.esize);
125        for _ in 0..self.esize {
126            let (from, to) = (U::scan(iter)?, U::scan(iter)?);
127            if self.directed {
128                graph.add_edge(from, to);
129            } else {
130                graph.add_undirected_edge(from, to);
131            }
132            rest.push(T::scan(iter)?);
133        }
134        Some((graph, rest))
135    }
Source

pub fn vertices(&self) -> Range<usize> ⓘ

Trait Implementations§

Source§

impl Clone for AdjacencyListGraph

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for AdjacencyListGraph

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AdjacencyListGraph

Source§

fn default() -> Self

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

impl<T> EdgeMap<T> for AdjacencyListGraph

Source§

type Emap = Vec<T>

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

Source§

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

Source§

impl Graph for AdjacencyListGraph

Source§

type Vertex = usize

Source§

type Label = usize

Source§

type Vertices<'g> = Range<usize>

Source§

type Neighbors<'g> = Copied<Iter<'g, Neighbor<usize, usize>>>

Source§

fn vsize(&self) -> usize

Source§

fn vertices(&self) -> Self::Vertices<'_>

Source§

fn neighbors(&self, vertex: Self::Vertex) -> Self::Neighbors<'_>

Source§

impl<T> VertexMap<T> for AdjacencyListGraph

Source§

type Vmap = Vec<T>

Source§

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

Source§

fn vmap_get<'a>(&self, map: &'a Self::Vmap, vertex: Self::Vertex) -> &'a T

Source§

fn vmap_get_mut<'a>( &self, map: &'a mut Self::Vmap, vertex: Self::Vertex, ) -> &'a mut T

Source§

fn vmap_set(&self, map: &mut Self::Vmap, vertex: Self::Vertex, value: T)

Auto Trait Implementations§

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<G> GraphOrderExt for G
where G: Graph + ?Sized,

Source§

fn bfs_order(&self, root: Self::Vertex) -> Vec<Self::Vertex>
where Self: VertexMap<bool>,

Source§

fn dfs_order(&self, root: Self::Vertex) -> Vec<Self::Vertex>
where Self: VertexMap<bool>,

Source§

fn dfs_tree(&self, root: Self::Vertex) -> <Self as EdgeMap<bool>>::Emap
where Self: EdgeMap<bool> + VertexMap<bool>,

Source§

fn for_each_connected_components<F>(&self, f: F)
where Self: VertexMap<bool>, F: FnMut(&Self, Self::Vertex, &[(Self::Vertex, Option<Self::Vertex>)]),

f: |g, root, ord: [vertex, parent]| {}
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<G> ShortestPathExt for G
where G: Graph + ?Sized,

Source§

fn standard_sp<'a, M>(&'a self) -> ShortestPathBuilder<'a, Self, StandardSp<M>>
where Self: Sized, M: Monoid<T: Bounded + Ord>,

Source§

fn standard_sp_additive<'a, T>( &'a self, ) -> ShortestPathBuilder<'a, Self, StandardSp<AdditiveOperation<T>>>
where Self: Sized, T: Clone + Zero + Add<Output = T> + Bounded + Ord,

Source§

fn option_sp<'a, M>(&'a self) -> ShortestPathBuilder<'a, Self, OptionSp<M>>
where Self: Sized, M: Monoid<T: Ord>,

Source§

fn option_sp_additive<'a, T>( &'a self, ) -> ShortestPathBuilder<'a, Self, OptionSp<AdditiveOperation<T>>>
where Self: Sized, T: Clone + Zero + Add<Output = T> + Ord,

Source§

fn path_folding_sp<'a, M, S>( &'a self, ) -> ShortestPathBuilder<'a, Self, PathFoldingSp<M, S>>
where Self: Sized, M: Monoid<T: Bounded + Ord>, S: SemiRing,

Source§

fn path_folding_sp_additive_addmul<'a, T, U>( &'a self, ) -> ShortestPathBuilder<'a, Self, PathFoldingSp<AdditiveOperation<T>, AddMulOperation<U>>>
where Self: Sized, T: Clone + Zero + Add<Output = T> + Bounded + Ord, U: DotProduct + One,

Source§

impl<G> SteinerTreeExt for G
where G: Graph + ?Sized,

Source§

fn steiner_tree(&self) -> SteinerTreeBuilder<'_, Self>
where Self: Sized,

Source§

impl<T> ToArrayVecScalar for T

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.