pub struct Maximum<T> {
pub value: T,
pub vertex: VertexId,
}Expand description
The maximum of a per-vertex measure and the vertex attaining it, the
Rust counterpart of the C pair igraph_vector_max() /
igraph_vector_which_max().
Fields§
§value: TThe largest value.
vertex: VertexIdThe (first) vertex attaining it.
Implementations§
Source§impl<T: PartialOrd + Copy> Maximum<T>
impl<T: PartialOrd + Copy> Maximum<T>
Sourcepub fn of(values: &[T]) -> Option<Self>
pub fn of(values: &[T]) -> Option<Self>
The largest element of values (indexed by vertex id) and its index,
or None for an empty slice.
It behaves exactly like igraph’s igraph_vector_max() and
igraph_vector_which_max(): the first maximal element wins ties,
and if values contains a NaN (for floating-point types: any
element not comparable with itself), the first NaN and its index are
returned.
§Examples
use igraph::tutorial::Maximum;
assert_eq!(Maximum::of(&[3, 7, 1, 7]), Some(Maximum { value: 7, vertex: 1 }));
assert_eq!(Maximum::<f64>::of(&[]), None);
// As in igraph, a NaN is the "maximum" of any vector containing one.
let m = Maximum::of(&[1.0, f64::NAN, 2.0]).unwrap();
assert!(m.value.is_nan() && m.vertex == 1);Trait Implementations§
impl<T: Copy> Copy for Maximum<T>
Source§impl<T: PartialEq> PartialEq for Maximum<T>
impl<T: PartialEq> PartialEq for Maximum<T>
impl<T: PartialEq> StructuralPartialEq for Maximum<T>
Auto Trait Implementations§
impl<T> Freeze for Maximum<T>where
T: Freeze,
impl<T> RefUnwindSafe for Maximum<T>where
T: RefUnwindSafe,
impl<T> Send for Maximum<T>where
T: Send,
impl<T> Sync for Maximum<T>where
T: Sync,
impl<T> Unpin for Maximum<T>where
T: Unpin,
impl<T> UnsafeUnpin for Maximum<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Maximum<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more