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§
Sourcefn sort_by_values(
&self,
reverse: bool,
) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>
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: Iftrue, 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.
Sourcefn top_k(
&self,
k: usize,
) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>
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: Iftrue, thekparameter is treated as a percentage of total elements.reverse: Iftrue, 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.
fn bottom_k( &self, k: usize, ) -> NodeState<'graph, Self::OwnedValue, Self::BaseGraph, Self::Graph>
Sourcefn min_item(
&self,
) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>
fn min_item( &self, ) -> Option<(NodeView<'_, &Self::BaseGraph, &Self::Graph>, Self::Value<'_>)>
Returns a tuple of the min result with its key
Provided Methods§
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.