Link

Struct Link 

Source
#[repr(C)]
pub struct Link<S, K, Ix = usize>
where S: RawDomain<Key = VertexId<Ix>>,
{ /* private fields */ }
Expand description

Here, a Link essentially defines the layout of an edge within a hypergraph. The implementation is generic over the type of domain it contains, which can be a set of vertices or any other structure that implements the Domain trait.

Implementations§

Source§

impl<S, K, Ix> Link<S, K, Ix>
where Ix: RawIndex, K: GraphType, S: Domain<Ix>,

Source

pub const fn new(id: EdgeId<Ix>, domain: S) -> Self

returns a new instance using the given edge id and domain

Source

pub fn from_id(id: EdgeId<Ix>) -> Self
where S: Default,

creates a new edge with the given id

Source

pub fn from_domain(nodes: S) -> Self
where Ix: Default,

creates a new edge with the given nodes

Source

pub const fn id(&self) -> &EdgeId<Ix>

returns an immutable reference to the id

Source

pub const fn domain(&self) -> &S

returns an immutable reference to the nodes

Source

pub const fn domain_mut(&mut self) -> &mut S

returns a mutable reference to the nodes

Source

pub fn set_domain(&mut self, nodes: S) -> &mut Self

updates the nodes and returns a mutable reference to the instance

Source

pub fn with_id(self, id: EdgeId<Ix>) -> Self

consumes the current instance to create another with the given id.

Source

pub fn with_domain<S2: Domain<Ix>>(self, nodes: S2) -> Link<S2, K, Ix>

consumes the current instance to create another with the given nodes.

Source

pub fn contains<Q>(&self, index: &Q) -> bool
where Ix: PartialEq, Q: ?Sized + PartialEq, VertexId<Ix>: Borrow<Q>, for<'a> &'a S: IntoIterator<Item = &'a VertexId<Ix>>,

returns true if the edge contains the given vertex index

Source

pub fn contains_all<Q, I>(&self, indices: I) -> bool
where Ix: PartialEq, I: IntoIterator<Item = Q>, Q: PartialEq, VertexId<Ix>: Borrow<Q>, for<'a> &'a S: IntoIterator<Item = &'a VertexId<Ix>>,

returns true if the edge contains all the given vertex indices

Source

pub fn len(&self) -> usize

returns the number of vertices in the edge

Source

pub fn is_empty(&self) -> bool

returns true if the edge has no vertices

Source§

impl<S, Idx> Link<S, Directed, Idx>
where Idx: RawIndex, S: Domain<Idx>,

Source

pub fn directed(id: EdgeId<Idx>, nodes: S) -> Self

returns a new Directed hyperedge with the given id and nodes

Source§

impl<S, Idx> Link<S, Undirected, Idx>
where Idx: RawIndex, S: Domain<Idx>,

Source

pub fn undirected(id: EdgeId<Idx>, nodes: S) -> Self

creates a new Undirected hyperedge with the given id and nodes

Methods from Deref<Target = EdgeId<Idx>>§

Source

pub fn as_ptr(&self) -> *const T

returns a pointer to the inner value

Source

pub fn as_mut_ptr(&mut self) -> *mut T

returns a mutable pointer to the inner value

Source

pub fn as_raw_box(&self) -> Box<dyn RawIndex>
where T: Clone,

converts the a reference to a boxed raw index trait object

Source

pub fn get(&self) -> &T

returns an immutable reference to the inner value

Source

pub fn get_mut(&mut self) -> &mut T

returns a mutable reference to the inner value

Source

pub fn replace(&mut self, index: T) -> T

replace and return the old value after replacing it with the given value

Source

pub fn set(&mut self, value: T) -> &mut Self

set the index to the given value

Source

pub fn swap(&mut self, other: &mut Self)

swap the values of two indices

Source

pub fn take(&mut self) -> T
where T: Default,

take the value and replace it with the default value

Source

pub fn dec_inplace(&mut self)
where T: SubAssign + One,

mutably decrements the index value by one

Source

pub fn inc_inplace(&mut self)
where T: Copy + AddAssign + One,

mutably increments the index value by 1

Source

pub fn step(&mut self) -> IndexResult<Self>
where T: AddStep<Output = T>,

increments the current index and returns the previous instance of the index.

    use rshyper_core::EdgeId;
    let mut edge_id = EdgeId::<usize>::zero();
    let e0 = edge_id.step()?;
    let e1 = edge_id.step()?;
    let e2 = edge_id.step()?;
    assert_eq!(e0.get(), &0);
    assert_eq!(e1.get(), &1);
    assert_eq!(e2.get(), &2);
Source

pub fn step_with<F>(&mut self, f: F) -> IndexResult<Self>
where F: FnOnce(&T) -> T,

replaces the current value with the next one computed using the provided function and returns the previous instance of the index.

Source

pub fn rand_step(&mut self) -> Self

replaces the current value with a randomly generated value and returns a new instance of IndexBase with the previous value.

Source

pub fn atomic_next(&mut self) -> Self

atomically generates a the next index, replacing the current value with the generated one and returning the previous value.

Source

pub fn generate(&mut self) -> Self

the generate is useful for instances where the type Idx of the IndexBase is not generalized, automatically using random number generation if the rand feature is enabled, or an atomic counter otherwise. The method is also useful in that it generates usize indices, whcih are the most common instances, yet aren’t direct implementors of StandardUniform.

Trait Implementations§

Source§

impl<S, K, Idx> AsMut<S> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn as_mut(&mut self) -> &mut S

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<S, K, Idx> AsRef<S> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn as_ref(&self) -> &S

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<S, I, K> BinaryLayout for Link<S, K, I>
where S: BinaryDomain<I>, I: RawIndex, K: GraphType,

Source§

fn lhs(&self) -> &VertexId<I>

Source§

fn rhs(&self) -> &VertexId<I>

Source§

impl<S, K, Idx> Borrow<IndexBase<Idx, EdgeIndex>> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn borrow(&self) -> &EdgeId<Idx>

Immutably borrows from an owned value. Read more
Source§

impl<S, K, Idx> BorrowMut<IndexBase<Idx, EdgeIndex>> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn borrow_mut(&mut self) -> &mut EdgeId<Idx>

Mutably borrows from an owned value. Read more
Source§

impl<S, K: Clone, Ix: Clone> Clone for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Clone,

Source§

fn clone(&self) -> Link<S, K, Ix>

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<S, K, Idx, Q> Contains<Q> for Link<S, K, Idx>
where Q: PartialEq, S: Domain<Idx>, K: GraphType, Idx: RawIndex + PartialEq, for<'a> &'a S: IntoIterator<Item = &'a VertexId<Idx>>,

Source§

type Key = IndexBase<Idx>

Source§

fn contains(&self, query: &Q) -> bool
where Self::Key: Borrow<Q>,

checks if the container contains the given index
Source§

impl<S, K, Idx> Debug for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx> + Debug,

Source§

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

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

impl<S, K, Idx> Default for Link<S, K, Idx>
where Idx: RawIndex + Default, K: GraphType, S: Domain<Idx> + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S, K, Idx> Deref for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

type Target = IndexBase<Idx, EdgeIndex>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S, K, Idx> DerefMut for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de, S, K, Ix> Deserialize<'de> for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Deserialize<'de>, Ix: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S, K, Idx> Display for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx> + Debug,

Source§

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

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

impl<T, S, K, Idx> From<Edge<T, S, K, Idx>> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn from(facet: Edge<T, S, K, Idx>) -> Self

Converts to this type from the input type.
Source§

impl<S, K, Idx> From<IndexBase<Idx, EdgeIndex>> for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Default + Domain<Idx>,

Source§

fn from(from: EdgeId<Idx>) -> Self

Converts to this type from the input type.
Source§

impl<T, S, K, Idx> From<Link<S, K, Idx>> for Edge<T, S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>, T: Default,

Source§

fn from(edge: Link<S, K, Idx>) -> Self

Converts to this type from the input type.
Source§

impl<S, K, Idx> From<Link<S, K, Idx>> for EdgeId<Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

fn from(from: Link<S, K, Idx>) -> Self

Converts to this type from the input type.
Source§

impl<S, K, Idx> FromIterator<Idx> for Link<S, K, Idx>
where Idx: Default + RawIndex, K: GraphType, S: Domain<Idx> + FromIterator<VertexId<Idx>>,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = Idx>,

Creates a value from an iterator. Read more
Source§

impl<S, K, Idx> FromIterator<IndexBase<Idx>> for Link<S, K, Idx>
where Idx: Default + RawIndex, K: GraphType, S: Domain<Idx> + FromIterator<VertexId<Idx>>,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = VertexId<Idx>>,

Creates a value from an iterator. Read more
Source§

impl<S, K: Hash, Ix: Hash> Hash for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S, K, Idx> Layout for Link<S, K, Idx>
where S: Domain<Idx>, Idx: RawIndex, K: GraphType,

Source§

fn new(id: EdgeId<Idx>, vertices: S) -> Self

Source§

impl<S, K: Ord, Ix: Ord> Ord for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Ord,

Source§

fn cmp(&self, other: &Link<S, K, Ix>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<S, K: PartialEq, Ix: PartialEq> PartialEq for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + PartialEq,

Source§

fn eq(&self, other: &Link<S, K, Ix>) -> bool

Tests for self and other values to be equal, and is used by ==.
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<S, K: PartialOrd, Ix: PartialOrd> PartialOrd for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + PartialOrd,

Source§

fn partial_cmp(&self, other: &Link<S, K, Ix>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<S, K, Idx> RawLayout for Link<S, K, Idx>
where Idx: RawIndex, K: GraphType, S: Domain<Idx>,

Source§

type Kind = K

Source§

type Index = Idx

Source§

type Store = S

Source§

fn index(&self) -> &EdgeId<Idx>

returns an immutable reference to the edge index
Source§

fn domain(&self) -> &S

returns a reference to the domain of the edge
Source§

fn domain_mut(&mut self) -> &mut S

returns a mutable reference to the domain of the edge
Source§

fn is_directed(&self) -> bool

returns true if the edge is directed, false otherwise.
Source§

fn is_undirected(&self) -> bool

returns true if the edge is undirected, false otherwise.
Source§

impl<S, K, Ix> Serialize for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Serialize, Ix: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S, K: Copy, Ix: Copy> Copy for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Copy,

Source§

impl<S, K: Eq, Ix: Eq> Eq for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>> + Eq,

Source§

impl<S, K, Ix> StructuralPartialEq for Link<S, K, Ix>
where S: RawDomain<Key = VertexId<Ix>>,

Auto Trait Implementations§

§

impl<S, K, Ix> Freeze for Link<S, K, Ix>
where S: Freeze, Ix: Freeze,

§

impl<S, K, Ix> RefUnwindSafe for Link<S, K, Ix>

§

impl<S, K, Ix> Send for Link<S, K, Ix>
where S: Send, Ix: Send, K: Send,

§

impl<S, K, Ix> Sync for Link<S, K, Ix>
where S: Sync, Ix: Sync, K: Sync,

§

impl<S, K, Ix> Unpin for Link<S, K, Ix>
where S: Unpin, Ix: Unpin, K: Unpin,

§

impl<S, K, Ix> UnwindSafe for Link<S, K, Ix>
where S: UnwindSafe, Ix: UnwindSafe, K: UnwindSafe,

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> AsWeight<T> for T
where T: Clone + IntoWeight<T>,

Source§

fn as_weight(&self) -> Weight<T>

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<T> ErrorKind for T
where T: Send + Sync + Debug + Display,

Source§

fn __private__(&self) -> Seal

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<K, S> Identity<K> for S
where S: Borrow<K>, K: Identifier,

Source§

type Item = S

Source§

fn get(&self) -> &<S as Identity<K>>::Item

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> IntoWeight<T> for T

Source§

impl<Q> RawState for Q
where Q: Send + Sync + Debug,

Source§

fn __private__(&self) -> Seal

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen<T>(&mut self) -> T

👎Deprecated since 0.9.0: Renamed to random to avoid conflict with the new gen keyword in Rust 2024.
Alias for Rng::random.
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

👎Deprecated since 0.9.0: Renamed to random_range
Source§

fn gen_bool(&mut self, p: f64) -> bool

👎Deprecated since 0.9.0: Renamed to random_bool
Alias for Rng::random_bool.
Source§

fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool

👎Deprecated since 0.9.0: Renamed to random_ratio
Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = Infallible

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

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>
where Self: Sized,

Convert an RngCore to a RngReadAdapter.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,