Struct GridGraph

Source
pub struct GridGraph<A> {
    pub height: usize,
    pub width: usize,
    /* private fields */
}

Fields§

§height: usize§width: usize

Implementations§

Source§

impl GridGraph<Adj4>

Source

pub fn new_adj4(height: usize, width: usize) -> Self

Source

pub fn adj4(&self, vid: (usize, usize)) -> GridAdjacency<'_, Adj4>

Examples found in repository?
crates/competitive/src/graph/grid.rs (line 151)
150    fn adjacencies(&self, vid: Self::VIndex) -> Self::AIter<'_> {
151        self.adj4(vid).map(Into::into)
152    }
Source§

impl GridGraph<Adj8>

Source

pub fn new_adj8(height: usize, width: usize) -> Self

Source

pub fn adj8(&self, vid: (usize, usize)) -> GridAdjacency<'_, Adj8>

Examples found in repository?
crates/competitive/src/graph/grid.rs (line 161)
160    fn adjacencies(&self, vid: Self::VIndex) -> Self::AIter<'_> {
161        self.adj8(vid).map(Into::into)
162    }
Source§

impl<A> GridGraph<A>

Source

pub fn new(height: usize, width: usize) -> Self

Examples found in repository?
crates/competitive/src/graph/grid.rs (line 16)
15    pub fn new_adj4(height: usize, width: usize) -> Self {
16        Self::new(height, width)
17    }
18    pub fn adj4(&self, vid: (usize, usize)) -> GridAdjacency<Adj4> {
19        GridAdjacency {
20            g: self,
21            xy: vid,
22            diter: GridDirectionIter::default(),
23            _marker: PhantomData,
24        }
25    }
26}
27impl GridGraph<Adj8> {
28    pub fn new_adj8(height: usize, width: usize) -> Self {
29        Self::new(height, width)
30    }
Source

pub fn move_by_diff( &self, xy: (usize, usize), dxdy: (isize, isize), ) -> Option<(usize, usize)>

Examples found in repository?
crates/competitive/src/graph/grid.rs (line 278)
276    fn next(&mut self) -> Option<Self::Item> {
277        for dir in self.diter.by_ref() {
278            match self.g.move_by_diff(self.xy, dir.dxdy()) {
279                Some(nxy) => return Some((nxy, dir)),
280                None => continue,
281            }
282        }
283        None
284    }
Source

pub fn flat(&self, xy: (usize, usize)) -> usize

Source

pub fn unflat(&self, pos: usize) -> (usize, usize)

Trait Implementations§

Source§

impl Adjacencies for GridGraph<Adj4>

Source§

type AIndex = VIndexWithValue<(usize, usize), GridDirection>

Source§

type AIter<'g> = Map<GridAdjacency<'g, Adj4>, fn(((usize, usize), GridDirection)) -> VIndexWithValue<(usize, usize), GridDirection>>

Source§

fn adjacencies(&self, vid: Self::VIndex) -> Self::AIter<'_>

Source§

impl Adjacencies for GridGraph<Adj8>

Source§

type AIndex = VIndexWithValue<(usize, usize), GridDirection>

Source§

type AIter<'g> = Map<GridAdjacency<'g, Adj8>, fn(((usize, usize), GridDirection)) -> VIndexWithValue<(usize, usize), GridDirection>>

Source§

fn adjacencies(&self, vid: Self::VIndex) -> Self::AIter<'_>

Source§

impl<'a, M, T> AdjacencyView<'a, M, T> for GridGraph<Adj4>
where M: 'a + Fn(GridDirection) -> T,

Source§

type AViewIter<'g> = AdjacencyViewIterFromValue<'g, 'a, GridGraph<Adj4>, M, GridDirection, T>

Source§

fn aviews<'g>(&'g self, map: &'a M, vid: Self::VIndex) -> Self::AViewIter<'g>

Source§

impl<'a, M, T> AdjacencyView<'a, M, T> for GridGraph<Adj8>
where M: 'a + Fn(GridDirection) -> T,

Source§

type AViewIter<'g> = AdjacencyViewIterFromValue<'g, 'a, GridGraph<Adj8>, M, GridDirection, T>

Source§

fn aviews<'g>(&'g self, map: &'a M, vid: Self::VIndex) -> Self::AViewIter<'g>

Source§

impl<A: Clone> Clone for GridGraph<A>

Source§

fn clone(&self) -> GridGraph<A>

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<A: Debug> Debug for GridGraph<A>

Source§

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

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

impl<A> GraphBase for GridGraph<A>

Source§

impl<A, T> VertexMap<T> for GridGraph<A>

Source§

type Vmap = Vec<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, (x, y): Self::VIndex) -> &'a T

Source§

fn vmap_get_mut<'a>( &self, map: &'a mut Self::Vmap, (x, y): Self::VIndex, ) -> &'a mut T

Source§

fn vmap_set(&self, map: &mut Self::Vmap, vid: Self::VIndex, x: T)

Source§

impl<A, T> VertexView<Vec<Vec<T>>, T> for GridGraph<A>
where T: Clone,

Source§

fn vview(&self, map: &Vec<Vec<T>>, vid: Self::VIndex) -> T

Source§

impl<A> Vertices for GridGraph<A>

Source§

type VIter<'g> = GridVertices where A: 'g

Source§

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

Source§

impl<A: Copy> Copy for GridGraph<A>

Auto Trait Implementations§

§

impl<A> Freeze for GridGraph<A>

§

impl<A> RefUnwindSafe for GridGraph<A>

§

impl<A> Send for GridGraph<A>

§

impl<A> Sync for GridGraph<A>

§

impl<A> Unpin for GridGraph<A>

§

impl<A> UnwindSafe for GridGraph<A>

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<G> ShortestPathExt for G
where G: GraphBase,

Source§

fn bfs_distance_ss<'a, S, M>( &self, source: Self::VIndex, weight: &'a M, ) -> <Self as VertexMap<S::T>>::Vmap
where Self: VertexMap<S::T> + AdjacencyView<'a, M, S::T>, S: ShortestPathSemiRing,

Source§

fn bfs_distance_ms<'a, S, M, I>( &self, sources: I, weight: &'a M, ) -> <Self as VertexMap<S::T>>::Vmap
where Self: VertexMap<S::T> + AdjacencyView<'a, M, S::T>, S: ShortestPathSemiRing, I: IntoIterator<Item = Self::VIndex>,

Source§

fn dijkstra_ss<'a, S, M>( &self, source: Self::VIndex, weight: &'a M, ) -> <Self as VertexMap<S::T>>::Vmap
where Self: VertexMap<S::T> + AdjacencyView<'a, M, S::T>, S: ShortestPathSemiRing,

Source§

fn dijkstra_ms<'a, S, M, I>( &self, sources: I, weight: &'a M, ) -> <Self as VertexMap<S::T>>::Vmap
where Self: VertexMap<S::T> + AdjacencyView<'a, M, S::T>, S: ShortestPathSemiRing, I: IntoIterator<Item = Self::VIndex>,

Source§

fn bellman_ford_ss<'a, S, M>( &self, source: Self::VIndex, weight: &'a M, check: bool, ) -> Option<<Self as VertexMap<S::T>>::Vmap>
where Self: Vertices + VertexMap<S::T> + AdjacencyView<'a, M, S::T> + VertexSize, S: ShortestPathSemiRing,

Source§

fn bellman_ford_ms<'a, S, M, I>( &self, sources: I, weight: &'a M, check: bool, ) -> Option<<Self as VertexMap<S::T>>::Vmap>
where Self: Vertices + VertexMap<S::T> + AdjacencyView<'a, M, S::T> + VertexSize, S: ShortestPathSemiRing, I: IntoIterator<Item = Self::VIndex>,

Source§

fn warshall_floyd_ap<'a, S, M>( &self, weight: &'a M, ) -> <Self as VertexMap<<Self as VertexMap<S::T>>::Vmap>>::Vmap
where Self: Vertices + VertexMap<S::T> + VertexMap<<Self as VertexMap<S::T>>::Vmap> + AdjacencyView<'a, M, S::T>, <Self as VertexMap<S::T>>::Vmap: Clone, S: ShortestPathSemiRing,

Source§

impl<G> SteinerTreeExt for G
where G: Vertices,

Source§

fn steiner_tree<'a, S, M, I>( &self, terminals: I, weight: &'a M, ) -> SteinerTreeOutput<'_, S, Self>
where Self: VertexMap<S::T> + AdjacencyView<'a, M, S::T>, S: ShortestPathSemiRing, I: IntoIterator<Item = Self::VIndex> + ExactSizeIterator,

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.
Source§

impl<G, F, T> VertexView<F, T> for G
where G: GraphBase, F: Fn(<G as GraphBase>::VIndex) -> T,

Source§

fn vview(&self, map: &F, vid: <G as GraphBase>::VIndex) -> T