WitnessHandle

Struct WitnessHandle 

Source
pub struct WitnessHandle { /* private fields */ }
Expand description

Handle to a witness (cheap to clone)

This is the primary type for passing witnesses around. It uses an Arc internally so cloning is O(1) and witnesses can be shared across threads.

§Examples

use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let mut membership = RoaringBitmap::new();
membership.insert(1);
membership.insert(2);
membership.insert(3);

let witness = WitnessHandle::new(1, membership, 4);
assert!(witness.contains(1));
assert!(witness.contains(2));
assert!(!witness.contains(5));
assert_eq!(witness.boundary_size(), 4);

Implementations§

Source§

impl WitnessHandle

Source

pub fn new( seed: VertexId, membership: RoaringBitmap, boundary_size: u64, ) -> Self

Create a new witness handle

§Arguments
  • seed - The seed vertex defining this cut (must be in membership)
  • membership - Bitmap of vertices in the cut set U
  • boundary_size - The size of the boundary |δ(U)|
§Panics

Panics if the seed vertex is not in the membership set (debug builds only)

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let mut membership = RoaringBitmap::new();
membership.insert(0);
membership.insert(1);

let witness = WitnessHandle::new(0, membership, 5);
assert_eq!(witness.seed(), 0);
Source

pub fn contains(&self, v: VertexId) -> bool

Check if vertex is in the cut set U

§Time Complexity

O(1) via bitmap lookup

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let mut membership = RoaringBitmap::new();
membership.insert(5);
membership.insert(10);

let witness = WitnessHandle::new(5, membership, 3);
assert!(witness.contains(5));
assert!(witness.contains(10));
assert!(!witness.contains(15));
Source

pub fn boundary_size(&self) -> u64

Get boundary size |δ(U)|

Returns the pre-computed boundary size for O(1) access.

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let witness = WitnessHandle::new(1, RoaringBitmap::from_iter([1, 2, 3]), 7);
assert_eq!(witness.boundary_size(), 7);
Source

pub fn seed(&self) -> VertexId

Get the seed vertex

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let witness = WitnessHandle::new(42, RoaringBitmap::from_iter([42u32]), 1);
assert_eq!(witness.seed(), 42);
Source

pub fn hash(&self) -> u64

Get the witness hash

Used for fast equality checks without comparing full membership sets.

Source

pub fn materialize_partition(&self) -> (HashSet<VertexId>, HashSet<VertexId>)

Materialize full partition (U, V \ U)

This is an expensive operation (O(|V|)) that converts the implicit representation into explicit sets. Use sparingly, primarily for debugging or verification.

§Returns

A tuple (U, V_minus_U) where:

  • U is the set of vertices in the cut
  • V_minus_U is the complement set
§Note

This method assumes vertices are numbered 0..max_vertex. For sparse graphs, V \ U may contain vertex IDs that don’t exist in the graph.

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;
use std::collections::HashSet;

let mut membership = RoaringBitmap::new();
membership.insert(1);
membership.insert(2);

let witness = WitnessHandle::new(1, membership, 3);
let (u, _v_minus_u) = witness.materialize_partition();

assert!(u.contains(&1));
assert!(u.contains(&2));
assert!(!u.contains(&3));
Source

pub fn cardinality(&self) -> u64

Get the cardinality of the cut set U

§Examples
use ruvector_mincut::instance::witness::WitnessHandle;
use roaring::RoaringBitmap;

let witness = WitnessHandle::new(1, RoaringBitmap::from_iter([1u32, 2u32, 3u32]), 5);
assert_eq!(witness.cardinality(), 3);

Trait Implementations§

Source§

impl Clone for WitnessHandle

Source§

fn clone(&self) -> WitnessHandle

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WitnessHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WitnessHandle

Source§

fn eq(&self, other: &Self) -> bool

Fast equality check using hash

First compares hashes (O(1)), then falls back to full comparison if needed.

1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Witness for WitnessHandle

Source§

fn contains(&self, v: VertexId) -> bool

Check if vertex is in the cut set U
Source§

fn boundary_size(&self) -> u64

Get boundary size |δ(U)|
Source§

fn materialize_partition(&self) -> (HashSet<VertexId>, HashSet<VertexId>)

Materialize full partition (expensive)
Source§

fn seed(&self) -> VertexId

Get the seed vertex
Source§

fn cardinality(&self) -> u64

Get cardinality of U
Source§

impl Eq for WitnessHandle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V