AsOrderedNodeStateOps

Trait AsOrderedNodeStateOps 

Source
pub trait AsOrderedNodeStateOps<'graph>: NodeStateOps<'graph> {
    // Required methods
    fn sort_by_values(
        &self,
        reverse: bool,
    ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>;
    fn top_k(
        &self,
        k: usize,
    ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>;
    fn bottom_k(
        &self,
        k: usize,
    ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>;
    fn min_item(
        &self,
    ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>;
    fn max_item(
        &self,
    ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>;
    fn median_item(
        &self,
    ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>;

    // Provided methods
    fn min(&self) -> Option<Self::Value<'_>> { ... }
    fn max(&self) -> Option<Self::Value<'_>> { ... }
    fn median(&self) -> Option<Self::Value<'_>> { ... }
}

Required Methods§

Source

fn sort_by_values( &self, reverse: bool, ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>

Sorts the AlgorithmResult by its values in ascending or descending order.

Arguments:

  • reverse: If true, sorts the result in descending order; otherwise, sorts in ascending order.

Returns:

A sorted vector of tuples containing keys of type H and values of type Y.

Source

fn top_k( &self, k: usize, ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>

Retrieves the top-k elements from the AlgorithmResult based on its values.

Arguments:

  • k: The number of elements to retrieve.
  • percentage: If true, the k parameter is treated as a percentage of total elements.
  • reverse: If true, retrieves the elements in descending order; otherwise, in ascending order.

Returns:

An a vector of tuples with keys of type Hand values of typeY. If percentageistrue, the returned vector contains the top kpercentage of elements. Ifpercentageisfalse, the returned vector contains the top kelements. Returns empty vec if the result is empty or ifk` is 0.

Source

fn bottom_k( &self, k: usize, ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>

Source

fn min_item( &self, ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>

Returns a tuple of the min result with its key

Source

fn max_item( &self, ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>

Returns a tuple of the max result with its key

Source

fn median_item( &self, ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>

Returns a tuple of the median result with its key

Provided Methods§

Source

fn min(&self) -> Option<Self::Value<'_>>

Min result.

Returns: PropValue:

Source

fn max(&self) -> Option<Self::Value<'_>>

Source

fn median(&self) -> Option<Self::Value<'_>>

Returns: PropValue:

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'graph, V: NodeStateOps<'graph>> AsOrderedNodeStateOps<'graph> for V
where for<'a> &'a V::OwnedValue: AsOrd,