petgraph::graph

Struct Frozen

Source
pub struct Frozen<'a, G: 'a>(/* private fields */);
Expand description

Frozen is a graph wrapper.

The Frozen only allows shared access (read-only) to the underlying graph G, but it allows mutable access to its node and edge weights.

This is used to ensure immutability of the graph’s structure while permitting weights to be both read and written.

See indexing implementations and the traits Data and DataMap for read-write access to the graph’s weights.

Implementations§

Source§

impl<'a, G> Frozen<'a, G>

Source

pub fn new(gr: &'a mut G) -> Self

Create a new Frozen from a mutable reference to a graph.

Source§

impl<'a, N, E, Ty, Ix> Frozen<'a, Graph<N, E, Ty, Ix>>
where Ty: EdgeType, Ix: IndexType,

Source

pub fn index_twice_mut<T, U>( &mut self, i: T, j: U, ) -> (&mut <Graph<N, E, Ty, Ix> as Index<T>>::Output, &mut <Graph<N, E, Ty, Ix> as Index<U>>::Output)
where Graph<N, E, Ty, Ix>: IndexMut<T> + IndexMut<U>, T: GraphIndex, U: GraphIndex,

Index the Graph by two indices, any combination of node or edge indices is fine.

Panics if the indices are equal or if they are out of bounds.

Trait Implementations§

Source§

impl<'a, G> Data for Frozen<'a, G>
where G: Data,

Source§

impl<'a, G> DataMap for Frozen<'a, G>
where G: DataMap,

Source§

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

Source§

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

Source§

impl<'a, G> DataMapMut for Frozen<'a, G>
where G: DataMapMut,

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<'a, G> Deref for Frozen<'a, G>

Deref allows transparent access to all shared reference (read-only) functionality in the underlying graph.

Source§

type Target = G

The resulting type after dereferencing.
Source§

fn deref(&self) -> &G

Dereferences the value.
Source§

impl<'a, G> EdgeCount for Frozen<'a, G>
where G: EdgeCount,

Source§

fn edge_count(&self) -> usize

Return the number of edges in the graph.
Source§

impl<'a, G> EdgeIndexable for Frozen<'a, G>
where G: EdgeIndexable,

Source§

fn edge_bound(&self) -> usize

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

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

Convert a to an integer index.
Source§

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

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

impl<'a, G> GetAdjacencyMatrix for Frozen<'a, G>

Source§

type AdjMatrix = <G as GetAdjacencyMatrix>::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<'a, G> GraphBase for Frozen<'a, G>
where G: GraphBase,

Source§

type NodeId = <G as GraphBase>::NodeId

node identifier
Source§

type EdgeId = <G as GraphBase>::EdgeId

edge identifier
Source§

impl<'a, G> GraphProp for Frozen<'a, G>
where G: GraphProp,

Source§

type EdgeType = <G as GraphProp>::EdgeType

The kind of edges in the graph.
Source§

fn is_directed(&self) -> bool

Source§

impl<'a, G, I> Index<I> for Frozen<'a, G>
where G: Index<I>,

Source§

type Output = <G as Index<I>>::Output

The returned type after indexing.
Source§

fn index(&self, i: I) -> &G::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, G, I> IndexMut<I> for Frozen<'a, G>
where G: IndexMut<I>,

Source§

fn index_mut(&mut self, i: I) -> &mut G::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, 'b, G> IntoEdgeReferences for &'b Frozen<'a, G>

Source§

impl<'a, 'b, G> IntoEdges for &'b Frozen<'a, G>
where G: IntoEdges,

Source§

type Edges = <G as IntoEdges>::Edges

Source§

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

Source§

impl<'a, 'b, G> IntoEdgesDirected for &'b Frozen<'a, G>

Source§

impl<'a, 'b, G> IntoNeighbors for &'b Frozen<'a, G>
where G: IntoNeighbors,

Source§

type Neighbors = <G as IntoNeighbors>::Neighbors

Source§

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

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

impl<'a, 'b, G> IntoNeighborsDirected for &'b Frozen<'a, G>

Source§

impl<'a, 'b, G> IntoNodeIdentifiers for &'b Frozen<'a, G>

Source§

impl<'a, 'b, G> IntoNodeReferences for &'b Frozen<'a, G>

Source§

impl<'a, G> NodeCount for Frozen<'a, G>
where G: NodeCount,

Source§

impl<'a, G> NodeIndexable for Frozen<'a, G>
where G: NodeIndexable,

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<'a, G> Visitable for Frozen<'a, G>
where G: Visitable,

Source§

type Map = <G as Visitable>::Map

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<'a, G> NodeCompactIndexable for Frozen<'a, G>

Auto Trait Implementations§

§

impl<'a, G> Freeze for Frozen<'a, G>

§

impl<'a, G> RefUnwindSafe for Frozen<'a, G>
where G: RefUnwindSafe,

§

impl<'a, G> Send for Frozen<'a, G>
where G: Send,

§

impl<'a, G> Sync for Frozen<'a, G>
where G: Sync,

§

impl<'a, G> Unpin for Frozen<'a, G>

§

impl<'a, G> !UnwindSafe for Frozen<'a, G>

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> 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, 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.