graaf/op/
arcs_weighted.rs

1//! Iterate a digraph's weighted arcs.
2//!
3//! # Examples
4//!
5//! ```
6//! use graaf::{
7//!     AddArcWeighted,
8//!     AdjacencyListWeighted,
9//!     ArcsWeighted,
10//!     Empty,
11//! };
12//!
13//! let mut digraph = AdjacencyListWeighted::empty(3);
14//!
15//! digraph.add_arc_weighted(0, 1, 2);
16//! digraph.add_arc_weighted(1, 2, 3);
17//! digraph.add_arc_weighted(2, 0, 4);
18//!
19//! assert!(digraph
20//!     .arcs_weighted()
21//!     .eq([(0, 1, &2), (1, 2, &3), (2, 0, &4)]));
22//! ```
23
24/// Weighted arcs
25pub trait ArcsWeighted {
26    /// The weight of an arc.
27    type Weight;
28
29    /// Iterate the digraph's weighted arcs.
30    ///
31    /// # Examples
32    ///
33    /// ```
34    /// use graaf::{
35    ///     AddArcWeighted,
36    ///     AdjacencyListWeighted,
37    ///     ArcsWeighted,
38    ///     Empty,
39    /// };
40    ///
41    /// let mut digraph = AdjacencyListWeighted::empty(3);
42    ///
43    /// digraph.add_arc_weighted(0, 1, 2);
44    /// digraph.add_arc_weighted(1, 2, 3);
45    /// digraph.add_arc_weighted(2, 0, 4);
46    ///
47    /// assert!(digraph
48    ///     .arcs_weighted()
49    ///     .eq([(0, 1, &2), (1, 2, &3), (2, 0, &4)]));
50    /// ```
51    #[must_use]
52    fn arcs_weighted(
53        &self,
54    ) -> impl Iterator<Item = (usize, usize, &Self::Weight)>;
55}