Skip to main content

GridGraph

Struct GridGraph 

Source
pub struct GridGraph<A> {
    pub height: usize,
    pub width: usize,
    _marker: PhantomData<fn() -> A>,
}

Fields§

§height: usize§width: usize§_marker: PhantomData<fn() -> A>

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

Source§

impl GridGraph<Adj8>

Source

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

Source

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

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 13)
12    pub fn new_adj4(height: usize, width: usize) -> Self {
13        Self::new(height, width)
14    }
15    pub fn adj4(&self, vid: (usize, usize)) -> GridAdjacency<'_, Adj4> {
16        GridAdjacency {
17            g: self,
18            xy: vid,
19            diter: GridDirectionIter::default(),
20            _marker: PhantomData,
21        }
22    }
23}
24impl GridGraph<Adj8> {
25    pub fn new_adj8(height: usize, width: usize) -> Self {
26        Self::new(height, width)
27    }
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 244)
242    fn next(&mut self) -> Option<Self::Item> {
243        for dir in self.diter.by_ref() {
244            match self.g.move_by_diff(self.xy, dir.dxdy()) {
245                Some(nxy) => return Some((nxy, dir)),
246                None => continue,
247            }
248        }
249        None
250    }
Source

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

Source

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

Trait Implementations§

Source§

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

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

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> Graph for GridGraph<A>

Source§

type Vertex = (usize, usize)

Source§

type Label = GridDirection

Source§

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

Source§

type Neighbors<'g> = Map<GridAdjacency<'g, A>, fn(((usize, usize), GridDirection)) -> Neighbor<(usize, usize), GridDirection>> where A: 'g

Source§

fn vsize(&self) -> usize

Source§

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

Source§

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

Source§

impl<A, T> VertexMap<T> for GridGraph<A>
where Self: Graph<Vertex = (usize, usize)>,

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, (x, y): Self::Vertex) -> &'a T

Source§

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

Source§

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

Auto Trait Implementations§

§

impl<A> Freeze for GridGraph<A>
where PhantomData<fn() -> A>: Freeze,

§

impl<A> RefUnwindSafe for GridGraph<A>
where PhantomData<fn() -> A>: RefUnwindSafe,

§

impl<A> Send for GridGraph<A>
where PhantomData<fn() -> A>: Send,

§

impl<A> Sync for GridGraph<A>
where PhantomData<fn() -> A>: Sync,

§

impl<A> Unpin for GridGraph<A>
where PhantomData<fn() -> A>: Unpin,

§

impl<A> UnsafeUnpin for GridGraph<A>
where PhantomData<fn() -> A>: UnsafeUnpin,

§

impl<A> UnwindSafe for GridGraph<A>
where PhantomData<fn() -> A>: 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<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.