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>
impl<N, E, Ix, S> SquareGraph<N, E, Ix, S>
Sourcepub unsafe fn new_raw(
nodes: FixedVec2D<N>,
horizontal: FixedVec2D<E>,
vertical: FixedVec2D<E>,
) -> Self
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
.
Sourcepub fn new(h: usize, v: usize) -> Self
pub fn new(h: usize, v: usize) -> Self
Create a SquareGraph
with the nodes and edges initialized with default.
Sourcepub fn new_with<FN, FE>(h: usize, v: usize, fnode: FN, fedge: FE) -> Self
pub fn new_with<FN, FE>(h: usize, v: usize, fnode: FN, fedge: FE) -> Self
Creates a SquareGraph
with initializing nodes and edges from position.
Sourcepub fn get_edge_id(
&self,
node: NodeIndex<Ix>,
dir: SquareDirection,
) -> Option<(EdgeIndex<Ix>, bool)>
pub fn get_edge_id( &self, node: NodeIndex<Ix>, dir: SquareDirection, ) -> Option<(EdgeIndex<Ix>, bool)>
Get the edge from node.
Sourcepub fn get_edge_reference<'a>(
&'a self,
n: NodeIndex<Ix>,
dir: SquareDirection,
) -> Option<EdgeReference<'a, E, Ix, S>>
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,
impl<N, E, Ix, S> SquareGraph<N, E, Ix, S>where
Ix: IndexType,
Sourcepub fn horizontal_node_count(&self) -> usize
pub fn horizontal_node_count(&self) -> usize
Returns the Node count in the horizontal direction.
Sourcepub fn vertical_node_count(&self) -> usize
pub fn vertical_node_count(&self) -> usize
Returns the Node count in the vertical direction.
Sourcepub fn horizontal(&self) -> &[&[E]]
pub fn horizontal(&self) -> &[&[E]]
Get a reference to the horizontal edges. [horizontal][vertical]
Sourcepub fn vertical(&self) -> &[&[E]]
pub fn vertical(&self) -> &[&[E]]
Get a reference to the vertical edges. [horizontal][vertical]
Sourcepub fn nodes_mut(&mut self) -> &mut [&mut [N]]
pub fn nodes_mut(&mut self) -> &mut [&mut [N]]
Get a mutable reference to the nodes. [horizontal][vertical]
Sourcepub fn horizontal_mut(&mut self) -> &[&mut [E]]
pub fn horizontal_mut(&mut self) -> &[&mut [E]]
Get a mutable reference to the horizontal edges. [horizontal][vertical]
Sourcepub fn vertical_mut(&mut self) -> &[&mut [E]]
pub fn vertical_mut(&mut self) -> &[&mut [E]]
Get a mutable reference to the vertical edges.
Trait Implementations§
Source§impl<N: Clone, E: Clone, Ix, S: Clone> Clone for SquareGraph<N, E, Ix, S>
impl<N: Clone, E: Clone, Ix, S: Clone> Clone for SquareGraph<N, E, Ix, S>
Source§fn clone(&self) -> SquareGraph<N, E, Ix, S>
fn clone(&self) -> SquareGraph<N, E, Ix, S>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<N, E, Ix, S> Data for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> Data for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
type NodeWeight = N
type EdgeWeight = E
Source§impl<N, E, Ix, S> DataMap for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> DataMap for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
fn node_weight(&self, id: Self::NodeId) -> Option<&Self::NodeWeight>
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,
impl<N, E, Ix, S> DataMapMut for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
fn node_weight_mut(&mut self, id: Self::NodeId) -> Option<&mut Self::NodeWeight>
fn edge_weight_mut(&mut self, id: Self::EdgeId) -> Option<&mut Self::EdgeWeight>
Source§impl<N, E, Ix, S> GraphBase for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> GraphBase for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
Source§impl<N, E, Ix, S> GraphProp for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> GraphProp for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
Source§type EdgeType = Undirected
type EdgeType = Undirected
fn is_directed(&self) -> bool
Source§impl<'a, N, E, Ix, S> IntoEdgeReferences for &'a SquareGraph<N, E, Ix, S>
impl<'a, N, E, Ix, S> IntoEdgeReferences for &'a SquareGraph<N, E, Ix, S>
type EdgeRef = EdgeReference<'a, E, Ix, S>
type EdgeReferences = EdgeReferences<'a, E, Ix, S>
fn edge_references(self) -> Self::EdgeReferences
Source§impl<'a, N, E, Ix, S> IntoEdges for &'a SquareGraph<N, E, Ix, S>
impl<'a, N, E, Ix, S> IntoEdges for &'a SquareGraph<N, E, Ix, S>
Source§impl<'a, N, E, Ix, S> IntoNeighbors for &'a SquareGraph<N, E, Ix, S>
impl<'a, N, E, Ix, S> IntoNeighbors for &'a SquareGraph<N, E, Ix, S>
Source§impl<'a, N, E, Ix, S> IntoNeighborsDirected for &'a SquareGraph<N, E, Ix, S>
impl<'a, N, E, Ix, S> IntoNeighborsDirected for &'a SquareGraph<N, E, Ix, S>
type NeighborsDirected = Neighbors<Ix, S>
fn neighbors_directed( self, n: Self::NodeId, _d: Direction, ) -> Self::NeighborsDirected
Source§impl<'a, N, E, Ix, S> IntoNodeIdentifiers for &'a SquareGraph<N, E, Ix, S>
impl<'a, N, E, Ix, S> IntoNodeIdentifiers for &'a SquareGraph<N, E, Ix, S>
type NodeIdentifiers = NodeIndices<Ix>
fn node_identifiers(self) -> Self::NodeIdentifiers
Source§impl<'a, N: Clone, E, Ix, S> IntoNodeReferences for &'a SquareGraph<N, E, Ix, S>
impl<'a, N: Clone, E, Ix, S> IntoNodeReferences for &'a SquareGraph<N, E, Ix, S>
type NodeRef = (NodeIndex<Ix>, &'a N)
type NodeReferences = NodeReferences<'a, N, Ix>
fn node_references(self) -> Self::NodeReferences
Source§impl<N, E, Ix, S> NodeCount for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> NodeCount for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
fn node_count(&self) -> usize
Source§impl<N, E, Ix, S> NodeIndexable for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
impl<N, E, Ix, S> NodeIndexable for SquareGraph<N, E, Ix, S>where
Ix: IndexType,
Source§fn node_bound(&self) -> usize
fn node_bound(&self) -> usize
Source§fn from_index(&self, i: usize) -> Self::NodeId
fn from_index(&self, i: usize) -> Self::NodeId
i
to a node index. i
must be a valid value in the graph.