Struct LatticeGraph

Source
pub struct LatticeGraph<N, E, S: Shape> { /* private fields */ }
Expand description

Abstract Lattice Graph. It holds the node and edge weight data. The actural behaviour is dependent on Shape.

Implementations§

Source§

impl<N, E, S: Shape> LatticeGraph<N, E, S>

Source

pub unsafe fn new_uninit(s: S) -> Self

Creates a graph with uninitalized node and edge weight data. It is extremely unsafe so should use with MaybeUninit and use assume_init.

Source

pub fn new(s: S) -> Self
where N: Default, E: Default,

Creates a graph with node and edge weight data set to default.

Source

pub fn new_with<FN, FE>(s: S, n: FN, e: FE) -> Self
where FN: FnMut(S::Coordinate) -> N, FE: FnMut(S::Coordinate, S::Axis) -> E,

Creates a graph with node and edge weight data from the coordinate.

Source

pub fn shape(&self) -> &S

Get a reference to the lattice graph’s s.

Source§

impl<N, E, S: Shape + Default> LatticeGraph<N, E, S>

Source

pub fn new_s() -> Self
where N: Default, E: Default,

Creates a graph with node and edge weight data set to default with Shape from default.

Source

pub unsafe fn new_uninit_s() -> Self

Creates a graph with uninitalized node and edge weight data with Shape from default. It is extremely unsafe so should use with MaybeUninit and use assume_init.

Source

pub fn new_with_s<FN, FE>(n: FN, e: FE) -> Self
where FN: FnMut(S::Coordinate) -> N, FE: FnMut(S::Coordinate, S::Axis) -> E,

Creates a graph with node and edge weight data from the coordinate with Shape from default.

Source§

impl<N, E, S: Shape> LatticeGraph<MaybeUninit<N>, MaybeUninit<E>, S>

Source

pub unsafe fn assume_init(self) -> LatticeGraph<N, E, S>

Assume the underlying nodes and edges to be initialized.

let mut hex = unsafe { HexGraphConst::<MaybeUninit<f32>, MaybeUninit<()>, OddR, 5, 5>::new_uninit_s() };
for i in 0..5{
    for j in 0..5{
        let offset = Offset::new(i, j);
        let coord = hex.shape().from_offset(offset);
        if let Some(ref mut n) = hex.node_weight_mut(coord){
            **n = MaybeUninit::new((i + j) as f32);
        }
    }
}
let hex_init = unsafe{ hex.assume_init() };

Trait Implementations§

Source§

impl<N: Clone, E: Clone, S: Clone + Shape> Clone for LatticeGraph<N, E, S>

Source§

fn clone(&self) -> LatticeGraph<N, E, S>

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<N, E, S: Shape> Data for LatticeGraph<N, E, S>

Source§

impl<N, E, S: Shape> DataMap for LatticeGraph<N, E, S>

Source§

fn node_weight(&self, id: Self::NodeId) -> Option<&Self::NodeWeight>

Source§

fn edge_weight(&self, id: Self::EdgeId) -> Option<&Self::EdgeWeight>

Source§

impl<N, E, S: Shape> DataMapMut for LatticeGraph<N, E, S>

Source§

fn node_weight_mut(&mut self, id: Self::NodeId) -> Option<&mut Self::NodeWeight>

Source§

fn edge_weight_mut(&mut self, id: Self::EdgeId) -> Option<&mut Self::EdgeWeight>

Source§

impl<N: Debug, E: Debug, S: Debug + Shape> Debug for LatticeGraph<N, E, S>

Source§

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

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

impl<N, E, S> Default for LatticeGraph<N, E, S>
where N: Default, E: Default, S: Shape + Default + Clone,

Source§

fn default() -> Self

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

impl<N, E, S: Shape> Drop for LatticeGraph<N, E, S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<N, E, S, C> GetAdjacencyMatrix for LatticeGraph<N, E, S>
where C: Copy + PartialEq, S: Shape<Coordinate = C>,

Source§

type AdjMatrix = ()

The associated adjacency matrix type
Source§

fn adjacency_matrix(&self) -> Self::AdjMatrix

Create the adjacency matrix
Source§

fn is_adjacent( &self, _matrix: &Self::AdjMatrix, a: Self::NodeId, b: Self::NodeId, ) -> bool

Return true if there is an edge from a to b, false otherwise. Read more
Source§

impl<N, E, S: Shape> GraphBase for LatticeGraph<N, E, S>

Source§

type NodeId = <S as Shape>::Coordinate

node identifier
Source§

type EdgeId = (<S as Shape>::Coordinate, <S as Shape>::Axis)

edge identifier
Source§

impl<N, E, S: Shape> GraphProp for LatticeGraph<N, E, S>

Source§

type EdgeType = EdgeTypeWrap<<S as Shape>::Axis>

The kind of edges in the graph.
Source§

fn is_directed(&self) -> bool

Source§

impl<N: Hash, E: Hash, S: Hash + Shape> Hash for LatticeGraph<N, E, S>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, N, E, S, C, D, A> IntoEdgeReferences for &'a LatticeGraph<N, E, S>
where C: Copy, S: Shape<Coordinate = C, Axis = A>, A: Axis<Direction = D>, D: AxisDirection + Copy,

Source§

impl<'a, N, E, S, C, D, A> IntoEdges for &'a LatticeGraph<N, E, S>
where C: Copy, S: Shape<Coordinate = C, Axis = A>, A: Axis<Direction = D>, D: AxisDirection + Copy,

Source§

type Edges = Edges<'a, N, E, S>

Source§

fn edges(self, a: Self::NodeId) -> Self::Edges

Source§

impl<'a, N, E, S, C, D, A> IntoEdgesDirected for &'a LatticeGraph<N, E, S>
where C: Copy, S: Shape<Coordinate = C, Axis = A>, A: Axis<Direction = D>, D: AxisDirection + Copy,

Source§

type EdgesDirected = Edges<'a, N, E, S, <S as Shape>::Coordinate, Direction>

Source§

fn edges_directed(self, a: Self::NodeId, dir: Direction) -> Self::EdgesDirected

Source§

impl<'a, N, E, S, D> IntoNeighbors for &'a LatticeGraph<N, E, S>
where S: Shape, S::Axis: Axis<Direction = D>, D: AxisDirection + Clone,

Source§

type Neighbors = Neighbors<'a, N, E, S>

Source§

fn neighbors(self, a: Self::NodeId) -> Self::Neighbors

Return an iterator of the neighbors of node a.
Source§

impl<'a, N, E, S, D> IntoNeighborsDirected for &'a LatticeGraph<N, E, S>
where S: Shape, S::Axis: Axis<Direction = D>, D: AxisDirection + Clone,

Source§

type NeighborsDirected = Neighbors<'a, N, E, S>

Source§

fn neighbors_directed(self, a: Self::NodeId, _d: Direction) -> Self::Neighbors

Source§

impl<'a, N, E, S: Shape> IntoNodeIdentifiers for &'a LatticeGraph<N, E, S>

Source§

impl<'a, N, E, S: Shape> IntoNodeReferences for &'a LatticeGraph<N, E, S>

Source§

impl<N, E, S: Shape> NodeCount for LatticeGraph<N, E, S>

Source§

impl<N, E, S: Shape> NodeIndexable for LatticeGraph<N, E, S>

Source§

fn node_bound(&self) -> usize

Return an upper bound of the node indices in the graph (suitable for the size of a bitmap).
Source§

fn to_index(&self, a: Self::NodeId) -> usize

Convert a to an integer index.
Source§

fn from_index(&self, i: usize) -> Self::NodeId

Convert i to a node index. i must be a valid value in the graph.
Source§

impl<N: PartialEq, E: PartialEq, S: PartialEq + Shape> PartialEq for LatticeGraph<N, E, S>

Source§

fn eq(&self, other: &LatticeGraph<N, E, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N, E, S: Shape + Clone> Visitable for LatticeGraph<N, E, S>

Source§

type Map = VisMap<S>

The associated map type
Source§

fn visit_map(&self) -> Self::Map

Create a new visitor map
Source§

fn reset_map(&self, map: &mut Self::Map)

Reset the visitor map (and resize to new size of graph if needed)
Source§

impl<N: Eq, E: Eq, S: Eq + Shape> Eq for LatticeGraph<N, E, S>

Source§

impl<N, E, S: Shape> NodeCompactIndexable for LatticeGraph<N, E, S>

Source§

impl<N, E, S: Shape> StructuralPartialEq for LatticeGraph<N, E, S>

Auto Trait Implementations§

§

impl<N, E, S> Freeze for LatticeGraph<N, E, S>
where S: Freeze,

§

impl<N, E, S> RefUnwindSafe for LatticeGraph<N, E, S>

§

impl<N, E, S> Send for LatticeGraph<N, E, S>
where S: Send, N: Send, E: Send,

§

impl<N, E, S> Sync for LatticeGraph<N, E, S>
where S: Sync, N: Sync, E: Sync,

§

impl<N, E, S> Unpin for LatticeGraph<N, E, S>
where S: Unpin,

§

impl<N, E, S> UnwindSafe for LatticeGraph<N, E, S>

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> ConstOrValue<T> for T

Source§

const IS_CONST_WRAP: bool = false

get wheter the type is const generic wrapper.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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<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.