use crate::PartitionId;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct CoherenceScore(u16);
impl CoherenceScore {
pub const MAX: Self = Self(10_000);
pub const MIN: Self = Self(0);
pub const DEFAULT_THRESHOLD: Self = Self(3_000);
pub const DEFAULT_MERGE_THRESHOLD: Self = Self(7_000);
#[must_use]
pub const fn from_basis_points(bp: u16) -> Self {
if bp > 10_000 {
Self(10_000)
} else {
Self(bp)
}
}
#[must_use]
pub const fn as_basis_points(self) -> u16 {
self.0
}
#[must_use]
pub const fn meets_threshold(self, threshold: Self) -> bool {
self.0 >= threshold.0
}
#[must_use]
pub const fn is_coherent(self) -> bool {
self.0 >= Self::DEFAULT_THRESHOLD.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct PhiValue(u32);
impl PhiValue {
pub const ZERO: Self = Self(0);
#[must_use]
pub const fn from_fixed(val: u32) -> Self {
Self(val)
}
#[must_use]
pub const fn as_fixed(self) -> u32 {
self.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct CutPressure(u32);
impl CutPressure {
pub const ZERO: Self = Self(0);
pub const DEFAULT_SPLIT_THRESHOLD: Self = Self(8_000);
#[must_use]
pub const fn from_fixed(val: u32) -> Self {
Self(val)
}
#[must_use]
pub const fn as_fixed(self) -> u32 {
self.0
}
#[must_use]
pub const fn exceeds_threshold(self, threshold: Self) -> bool {
self.0 > threshold.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct CommEdgeId(u64);
impl CommEdgeId {
#[must_use]
pub const fn new(id: u64) -> Self {
Self(id)
}
#[must_use]
pub const fn as_u64(self) -> u64 {
self.0
}
}
#[derive(Debug, Clone, Copy)]
pub struct CommEdge {
pub id: CommEdgeId,
pub source: PartitionId,
pub dest: PartitionId,
pub weight: u64,
pub last_epoch: u32,
}