Skip to main content

SimdTraversal

Struct SimdTraversal 

Source
pub struct SimdTraversal;
Expand description

SIMD-accelerated operations for BFS/DFS distance and level vectors.

Provides optimized initialization, update, and reduction operations on the distance/level arrays used in graph traversals.

Implementations§

Source§

impl SimdTraversal

Source

pub fn init_distances(n: usize, source: usize) -> Array1<f64>

Initialize a distance vector with infinity (or a sentinel value).

Sets all entries to f64::INFINITY except the source node.

§Arguments
  • n - Number of nodes
  • source - Source node index
§Returns

Distance vector with distances[source] = 0.0 and all others infinity.

Source

pub fn init_distances_multi_source(n: usize, sources: &[usize]) -> Array1<f64>

Initialize a distance vector for multi-source BFS.

§Arguments
  • n - Number of nodes
  • sources - Slice of source node indices
§Returns

Distance vector with distances[s] = 0.0 for each source s.

Source

pub fn relax_neighbors( distances: &mut Array1<f64>, adjacency_row: &ArrayView1<'_, f64>, current_distance: f64, ) -> Vec<usize>

SIMD-accelerated BFS frontier relaxation.

For each node in the current frontier, attempts to relax the distance of its neighbors. This is the inner loop of BFS.

§Arguments
  • distances - Current distance vector (modified in place)
  • adjacency_row - Adjacency row for the current node
  • current_distance - Distance of the current node
§Returns

Vector of neighbor indices that were relaxed (for the next frontier).

Source

pub fn eccentricity(distances: &ArrayView1<'_, f64>) -> f64

Compute the eccentricity of a node from its distance vector.

The eccentricity is the maximum finite distance to any reachable node.

§Arguments
  • distances - Distance vector from a single source
§Returns

The eccentricity value. Returns 0.0 if no nodes are reachable.

Source

pub fn count_reachable(distances: &ArrayView1<'_, f64>) -> usize

Count the number of reachable nodes from a distance vector using SIMD.

A node is reachable if its distance is finite.

§Arguments
  • distances - Distance vector from a single source
§Returns

Number of reachable nodes (including the source itself).

Source

pub fn sum_finite_distances(distances: &ArrayView1<'_, f64>) -> f64

Compute the sum of finite distances using SIMD.

Used for computing closeness centrality: C(v) = (n-1) / sum(d(v, w)).

§Arguments
  • distances - Distance vector from a single source
§Returns

Sum of all finite distances.

Source

pub fn element_wise_min( a: &ArrayView1<'_, f64>, b: &ArrayView1<'_, f64>, ) -> Array1<f64>

SIMD-accelerated element-wise minimum of two distance vectors.

Useful for merging BFS trees or computing all-pairs shortest paths.

§Arguments
  • a - First distance vector
  • b - Second distance vector
§Returns

Element-wise minimum vector.

Source

pub fn diameter_from_distance_matrix( distance_matrix: &ArrayView2<'_, f64>, ) -> f64

Compute the diameter of a graph from an all-pairs distance matrix.

The diameter is the maximum eccentricity over all nodes.

§Arguments
  • distance_matrix - All-pairs distance matrix (n x n)
§Returns

The graph diameter. Returns 0.0 for empty or disconnected graphs.

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> 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, 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