Trait coupe::Topology

source ·
pub trait Topology<E> {
    type Neighbors<'n>: Iterator<Item = (usize, E)>
       where Self: 'n;

    // Required methods
    fn len(&self) -> usize;
    fn neighbors(&self, vertex: usize) -> Self::Neighbors<'_>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn edge_cut(&self, partition: &[usize]) -> E
       where Self: Sync,
             E: Sum + Send { ... }
    fn lambda_cut<W>(&self, partition: &[usize], weights: W) -> W::Item
       where Self: Sync,
             W: IntoParallelIterator,
             W::Iter: IndexedParallelIterator,
             W::Item: Sum + Mul<Output = W::Item> + FromPrimitive { ... }
}
Expand description

Topology is implemented for types that represent mesh topology.

Required Associated Types§

source

type Neighbors<'n>: Iterator<Item = (usize, E)> where Self: 'n

Return type for Topology::neighbors.

This is an implementation detail and will be removed when Rust allows us to do so (at most when async fns are allowed in traits).

Required Methods§

source

fn len(&self) -> usize

The number of elements in the mesh.

source

fn neighbors(&self, vertex: usize) -> Self::Neighbors<'_>

An iterator over the neighbors of the given vertex.

Provided Methods§

source

fn is_empty(&self) -> bool

Whether the topology has no elements.

source

fn edge_cut(&self, partition: &[usize]) -> Ewhere Self: Sync, E: Sum + Send,

The edge cut of a partition.

Given a partition and a weighted graph associated to a mesh, the edge cut of a partition is defined as the total weight of the edges that link graph nodes of different parts.

Example

A partition with two parts (0 and 1)

         0
   1*──┆─*────* 0
   ╱ ╲ ┆╱    ╱
 1*  1*┆ <┈┈╱┈┈┈ Dotted line passes through edged that contribute to edge cut.
   ╲ ╱ ┆   ╱     If all edges have a weight of 1 then edge_cut = 3
   1*  ┆╲ ╱
         * 0
source

fn lambda_cut<W>(&self, partition: &[usize], weights: W) -> W::Itemwhere Self: Sync, W: IntoParallelIterator, W::Iter: IndexedParallelIterator, W::Item: Sum + Mul<Output = W::Item> + FromPrimitive,

The λ-1 cut (lambda-1 cut) of a partition.

The λ-1 cut is the sum, for each vertex, of the number of different parts in its neighborhood times its communication weight.

This metric better represents the actual communication cost of a partition, albeit more expensive to compute.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, E> Topology<E> for CsMatView<'a, E>where E: Copy + Sync,

§

type Neighbors<'n> = Zip<Cloned<Iter<'n, usize>>, Cloned<Iter<'n, E>>> where Self: 'n

source§

fn len(&self) -> usize

source§

fn neighbors(&self, vertex: usize) -> Self::Neighbors<'_>

source§

fn edge_cut(&self, partition: &[usize]) -> Ewhere E: Sum + Send,

source§

fn lambda_cut<W>(&self, partition: &[usize], weights: W) -> W::Itemwhere W: IntoParallelIterator, W::Iter: IndexedParallelIterator, W::Item: Sum + Mul<Output = W::Item> + FromPrimitive,

source§

impl<'a, T, E> Topology<E> for &'a Twhere E: Copy, T: Topology<E>,

§

type Neighbors<'n> = <T as Topology<E>>::Neighbors<'n> where Self: 'n

source§

fn len(&self) -> usize

source§

fn neighbors(&self, vertex: usize) -> Self::Neighbors<'_>

Implementors§

source§

impl<const D: usize, E> Topology<E> for Grid<D>where E: One,

§

type Neighbors<'a> = GridNeighbors<D, E> where Self: 'a