Struct petgraph::csr::Csr [−][src]
Expand description
Compressed Sparse Row (CSR
) is a sparse adjacency matrix graph.
CSR
is parameterized over:
- Associated data
N
for nodes andE
for edges, called weights. The associated data can be of arbitrary type. - Edge type
Ty
that determines whether the graph edges are directed or undirected. - Index type
Ix
, which determines the maximum size of the graph.
Using O(|E| + |V|) space.
Self loops are allowed, no parallel edges.
Fast iteration of the outgoing edges of a vertex.
Implementations
impl<N, E, Ty, Ix> Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]pub fn with_nodes(n: usize) -> Self where
N: Default,
[src]
pub fn with_nodes(n: usize) -> Self where
N: Default,
[src]impl<N, E, Ix> Csr<N, E, Directed, Ix> where
Ix: IndexType,
[src]
impl<N, E, Ix> Csr<N, E, Directed, Ix> where
Ix: IndexType,
[src]pub fn from_sorted_edges<Edge>(edges: &[Edge]) -> Result<Self, EdgesNotSorted> where
Edge: Clone + IntoWeightedEdge<E, NodeId = NodeIndex<Ix>>,
N: Default,
[src]
pub fn from_sorted_edges<Edge>(edges: &[Edge]) -> Result<Self, EdgesNotSorted> where
Edge: Clone + IntoWeightedEdge<E, NodeId = NodeIndex<Ix>>,
N: Default,
[src]Create a new Csr
from a sorted sequence of edges
Edges must be sorted and unique, where the sort order is the default order for the pair (u, v) in Rust (u has priority).
Computes in O(|E| + |V|) time.
Example
use petgraph::csr::Csr; use petgraph::prelude::*; let graph = Csr::<(),()>::from_sorted_edges(&[ (0, 1), (0, 2), (1, 0), (1, 2), (1, 3), (2, 0), (3, 1), ]);
impl<N, E, Ty, Ix> Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]pub fn node_count(&self) -> usize
[src]
pub fn edge_count(&self) -> usize
[src]
pub fn is_directed(&self) -> bool
[src]
pub fn clear_edges(&mut self)
[src]
pub fn clear_edges(&mut self)
[src]Remove all edges
pub fn add_node(&mut self, weight: N) -> NodeIndex<Ix>
[src]
pub fn add_node(&mut self, weight: N) -> NodeIndex<Ix>
[src]Adds a new node with the given weight, returning the corresponding node index.
pub fn add_edge(
&mut self,
a: NodeIndex<Ix>,
b: NodeIndex<Ix>,
weight: E
) -> bool where
E: Clone,
[src]
pub fn add_edge(
&mut self,
a: NodeIndex<Ix>,
b: NodeIndex<Ix>,
weight: E
) -> bool where
E: Clone,
[src]Return true
if the edge was added
If you add all edges in row-major order, the time complexity is O(|V|·|E|) for the whole operation.
Panics if a
or b
are out of bounds.
pub fn contains_edge(&self, a: NodeIndex<Ix>, b: NodeIndex<Ix>) -> bool
[src]
pub fn contains_edge(&self, a: NodeIndex<Ix>, b: NodeIndex<Ix>) -> bool
[src]Computes in O(log |V|) time.
Panics if the node a
does not exist.
pub fn out_degree(&self, a: NodeIndex<Ix>) -> usize
[src]
pub fn out_degree(&self, a: NodeIndex<Ix>) -> usize
[src]Computes in O(1) time.
Panics if the node a
does not exist.
pub fn neighbors_slice(&self, a: NodeIndex<Ix>) -> &[NodeIndex<Ix>]
[src]
pub fn neighbors_slice(&self, a: NodeIndex<Ix>) -> &[NodeIndex<Ix>]
[src]Computes in O(1) time.
Panics if the node a
does not exist.
pub fn edges_slice(&self, a: NodeIndex<Ix>) -> &[E]
[src]
pub fn edges_slice(&self, a: NodeIndex<Ix>) -> &[E]
[src]Computes in O(1) time.
Panics if the node a
does not exist.
Trait Implementations
impl<N, E, Ty, Ix> Data for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> Data for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]type NodeWeight = N
type EdgeWeight = E
impl<N, E, Ty, Ix> GraphProp for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> GraphProp for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]type EdgeType = Ty
type EdgeType = Ty
The kind edges in the graph.
fn is_directed(&self) -> bool
[src]
impl<'a, N, E, Ty, Ix> IntoEdgeReferences for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<'a, N, E, Ty, Ix> IntoEdgeReferences for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]type EdgeRef = EdgeReference<'a, E, Ty, Ix>
type EdgeReferences = EdgeReferences<'a, E, Ty, Ix>
fn edge_references(self) -> Self::EdgeReferences
[src]
impl<'a, N, E, Ty, Ix> IntoNeighbors for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<'a, N, E, Ty, Ix> IntoNeighbors for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]fn neighbors(self, a: Self::NodeId) -> Self::Neighbors
[src]
fn neighbors(self, a: Self::NodeId) -> Self::Neighbors
[src]Return an iterator of all neighbors of a
.
Directed
: Targets of outgoing edges froma
.Undirected
: Opposing endpoints of all edges connected toa
.
Panics if the node a
does not exist.
Iterator element type is NodeIndex<Ix>
.
type Neighbors = Neighbors<'a, Ix>
impl<'a, N, E, Ty, Ix> IntoNodeIdentifiers for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<'a, N, E, Ty, Ix> IntoNodeIdentifiers for &'a Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]type NodeIdentifiers = NodeIdentifiers<Ix>
fn node_identifiers(self) -> Self::NodeIdentifiers
[src]
impl<N, E, Ty, Ix> NodeCount for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> NodeCount for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]fn node_count(&self) -> usize
[src]
impl<N, E, Ty, Ix> NodeIndexable for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> NodeIndexable for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]impl<N, E, Ty, Ix> Visitable for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
impl<N, E, Ty, Ix> Visitable for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]type Map = FixedBitSet
type Map = FixedBitSet
The associated map type
fn visit_map(&self) -> FixedBitSet
[src]
fn visit_map(&self) -> FixedBitSet
[src]Create a new visitor map
impl<N, E, Ty, Ix> NodeCompactIndexable for Csr<N, E, Ty, Ix> where
Ty: EdgeType,
Ix: IndexType,
[src]
Ty: EdgeType,
Ix: IndexType,
Auto Trait Implementations
impl<N, E, Ty, Ix> RefUnwindSafe for Csr<N, E, Ty, Ix> where
E: RefUnwindSafe,
Ix: RefUnwindSafe,
N: RefUnwindSafe,
Ty: RefUnwindSafe,
E: RefUnwindSafe,
Ix: RefUnwindSafe,
N: RefUnwindSafe,
Ty: RefUnwindSafe,
impl<N, E, Ty, Ix> Send for Csr<N, E, Ty, Ix> where
E: Send,
Ix: Send,
N: Send,
Ty: Send,
E: Send,
Ix: Send,
N: Send,
Ty: Send,
impl<N, E, Ty, Ix> Sync for Csr<N, E, Ty, Ix> where
E: Sync,
Ix: Sync,
N: Sync,
Ty: Sync,
E: Sync,
Ix: Sync,
N: Sync,
Ty: Sync,
impl<N, E, Ty, Ix> Unpin for Csr<N, E, Ty, Ix> where
E: Unpin,
Ix: Unpin,
N: Unpin,
Ty: Unpin,
E: Unpin,
Ix: Unpin,
N: Unpin,
Ty: Unpin,
impl<N, E, Ty, Ix> UnwindSafe for Csr<N, E, Ty, Ix> where
E: UnwindSafe,
Ix: UnwindSafe,
N: UnwindSafe,
Ty: UnwindSafe,
E: UnwindSafe,
Ix: UnwindSafe,
N: UnwindSafe,
Ty: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more