Struct SquareGraph

Source
pub struct SquareGraph<N, E, Ix = usize, S = DefaultShape>
where Ix: IndexType,
{ /* private fields */ }
Expand description

Undirected Square Grid Graph. It is has rectangle shape.

Node(i,j+1) - Edge(i,j+1,Horizontal) - Node(i+1,j+1)
  |                                     |
Edge(i,j,Vertical)                     Edge(i+1,j,Vertical)
  |                                     |
Node(i,j)   - Edge(i,j,Horizontal)   - Node(i+1,j)

Implementations§

Source§

impl<N, E, Ix, S> SquareGraph<N, E, Ix, S>
where Ix: IndexType, S: Shape,

Source

pub unsafe fn new_raw( nodes: FixedVec2D<N>, horizontal: FixedVec2D<E>, vertical: FixedVec2D<E>, ) -> Self

Create a SquareGraph from raw data. It only check whether the size of nodes and edges are correct in debug_assertion.

Source

pub fn new(h: usize, v: usize) -> Self
where N: Default, E: Default,

Create a SquareGraph with the nodes and edges initialized with default.

Source

pub fn new_with<FN, FE>(h: usize, v: usize, fnode: FN, fedge: FE) -> Self
where FN: FnMut(usize, usize) -> N, FE: FnMut(usize, usize, Axis) -> E,

Creates a SquareGraph with initializing nodes and edges from position.

Source

pub fn get_edge_id( &self, node: NodeIndex<Ix>, dir: SquareDirection, ) -> Option<(EdgeIndex<Ix>, bool)>

Get the edge from node.

Source

pub fn get_edge_reference<'a>( &'a self, n: NodeIndex<Ix>, dir: SquareDirection, ) -> Option<EdgeReference<'a, E, Ix, S>>

Get the edge reference form node.

Source§

impl<N, E, Ix, S> SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source

pub fn horizontal_node_count(&self) -> usize

Returns the Node count in the horizontal direction.

Source

pub fn vertical_node_count(&self) -> usize

Returns the Node count in the vertical direction.

Source

pub fn nodes(&self) -> &[&[N]]

Get a reference to the nodes. [horizontal][vertical]

Source

pub fn horizontal(&self) -> &[&[E]]

Get a reference to the horizontal edges. [horizontal][vertical]

Source

pub fn vertical(&self) -> &[&[E]]

Get a reference to the vertical edges. [horizontal][vertical]

Source

pub fn nodes_mut(&mut self) -> &mut [&mut [N]]

Get a mutable reference to the nodes. [horizontal][vertical]

Source

pub fn horizontal_mut(&mut self) -> &[&mut [E]]

Get a mutable reference to the horizontal edges. [horizontal][vertical]

Source

pub fn vertical_mut(&mut self) -> &[&mut [E]]

Get a mutable reference to the vertical edges.

Source§

impl<E, Ix, S> SquareGraph<(), E, Ix, S>
where Ix: IndexType, S: Shape,

Source

pub fn new_edge_graph<FE>(h: usize, v: usize, fedge: FE) -> Self
where FE: FnMut(usize, usize, Axis) -> E,

Create a SquareGraph with the edges initialized from position.

Trait Implementations§

Source§

impl<N: Clone, E: Clone, Ix, S: Clone> Clone for SquareGraph<N, E, Ix, S>
where Ix: IndexType + Clone,

Source§

fn clone(&self) -> SquareGraph<N, E, Ix, 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, Ix, S> Data for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source§

impl<N, E, Ix, S> DataMap for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

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, Ix, S> DataMapMut for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

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, Ix, S: Debug> Debug for SquareGraph<N, E, Ix, S>
where Ix: IndexType + Debug,

Source§

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

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

impl<N, E, Ix, S> GraphBase for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source§

type NodeId = NodeIndex<Ix>

node identifier
Source§

type EdgeId = EdgeIndex<Ix>

edge identifier
Source§

impl<N, E, Ix, S> GraphProp for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source§

type EdgeType = Undirected

The kind of edges in the graph.
Source§

fn is_directed(&self) -> bool

Source§

impl<'a, N, E, Ix, S> IntoEdgeReferences for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, E: Copy, S: Shape,

Source§

impl<'a, N, E, Ix, S> IntoEdges for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, E: Copy, S: Shape,

Source§

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

Source§

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

Source§

impl<'a, N, E, Ix, S> IntoNeighbors for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, S: Shape,

Source§

type Neighbors = Neighbors<Ix, S>

Source§

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

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

impl<'a, N, E, Ix, S> IntoNeighborsDirected for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, S: Shape,

Source§

impl<'a, N, E, Ix, S> IntoNodeIdentifiers for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, Range<Ix>: Iterator<Item = Ix>,

Source§

impl<'a, N: Clone, E, Ix, S> IntoNodeReferences for &'a SquareGraph<N, E, Ix, S>
where Ix: IndexType, Range<Ix>: Iterator<Item = Ix>,

Source§

impl<N, E, Ix, S> NodeCount for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source§

impl<N, E, Ix, S> NodeIndexable for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

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, E, Ix, S> Visitable for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Source§

type Map = VisMap

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, E, Ix, S> NodeCompactIndexable for SquareGraph<N, E, Ix, S>
where Ix: IndexType,

Auto Trait Implementations§

§

impl<N, E, Ix, S> Freeze for SquareGraph<N, E, Ix, S>

§

impl<N, E, Ix, S> RefUnwindSafe for SquareGraph<N, E, Ix, S>

§

impl<N, E, Ix, S> Send for SquareGraph<N, E, Ix, S>
where N: Send, E: Send,

§

impl<N, E, Ix, S> Sync for SquareGraph<N, E, Ix, S>
where N: Sync, E: Sync,

§

impl<N, E, Ix, S> Unpin for SquareGraph<N, E, Ix, S>

§

impl<N, E, Ix, S> UnwindSafe for SquareGraph<N, E, Ix, 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<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.