Skip to main content

AllowedEdgeTypes

Struct AllowedEdgeTypes 

Source
pub struct AllowedEdgeTypes {
    pub loops: bool,
    pub multi: bool,
}
Expand description

Which kinds of edges a graph may contain, as a set of flags (igraph_edge_type_sw_t, including the combination IGRAPH_LOOPS_SW | IGRAPH_MULTI_SW).

This is the single crate-wide type for igraph’s edge-type switches: it is taken by the random generators of games (e.g. Graph::erdos_renyi_game_gnm), by the graphicality tests of mixing (e.g. is_graphical) and by the deterministic realizations of constructors (e.g. Graph::realize_degree_sequence). It is re-exported as games::AllowedEdgeTypes, mixing::AllowedEdgeTypes and constructors::AllowedEdgeTypes, and all these paths name the very same type.

Unlike EdgeTypeSw, which lists the three basic flags, this type can express their combination: build it with the associated constants (SIMPLE, LOOPS, MULTI, ALL), with a struct literal, or by or-ing flags together. Every function taking it accepts impl Into<AllowedEdgeTypes>, so an EdgeTypeSw can be passed directly.

use igraph::{ffi, prelude::*};

let both = AllowedEdgeTypes::LOOPS | AllowedEdgeTypes::MULTI;
assert_eq!(both, AllowedEdgeTypes::ALL);
assert_eq!(AllowedEdgeTypes::from(EdgeTypeSw::Multi), AllowedEdgeTypes::MULTI);
assert_eq!(EdgeTypeSw::Loops | EdgeTypeSw::Multi, AllowedEdgeTypes::ALL);

// Raw C flags, both ways.
let raw = ffi::igraph_edge_type_sw_t::from(AllowedEdgeTypes::ALL);
assert_eq!(raw, ffi::IGRAPH_LOOPS_SW | ffi::IGRAPH_MULTI_SW);
assert_eq!(AllowedEdgeTypes::try_from(raw).unwrap(), AllowedEdgeTypes::ALL);

// One name, one type, whatever the module path.
let t: igraph::games::AllowedEdgeTypes = igraph::constructors::AllowedEdgeTypes::MULTI;
assert_eq!(t, igraph::mixing::AllowedEdgeTypes::MULTI);

Fields§

§loops: bool

Whether self-loops are allowed.

§multi: bool

Whether multi-edges (parallel edges) are allowed.

Implementations§

Source§

impl AllowedEdgeTypes

Source

pub const SIMPLE: Self

Simple graphs only: neither self-loops nor multi-edges (IGRAPH_SIMPLE_SW).

Source

pub const LOOPS: Self

Self-loops allowed, but no multi-edges (IGRAPH_LOOPS_SW); at most one self-loop per vertex.

Source

pub const MULTI: Self

Multi-edges allowed, but no self-loops (IGRAPH_MULTI_SW).

Source

pub const ALL: Self

Both self-loops and multi-edges allowed (IGRAPH_LOOPS_SW | IGRAPH_MULTI_SW).

Source

pub const fn to_raw(self) -> igraph_edge_type_sw_t

The raw igraph bit flags.

Trait Implementations§

Source§

impl BitOr for AllowedEdgeTypes

Source§

type Output = AllowedEdgeTypes

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl BitOr<EdgeTypeSw> for AllowedEdgeTypes

Source§

type Output = AllowedEdgeTypes

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: EdgeTypeSw) -> Self

Performs the | operation. Read more
Source§

impl Clone for AllowedEdgeTypes

Source§

fn clone(&self) -> AllowedEdgeTypes

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for AllowedEdgeTypes

Source§

impl Debug for AllowedEdgeTypes

Source§

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

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

impl Default for AllowedEdgeTypes

Source§

fn default() -> AllowedEdgeTypes

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

impl Eq for AllowedEdgeTypes

Source§

impl From<AllowedEdgeTypes> for igraph_edge_type_sw_t

Source§

fn from(types: AllowedEdgeTypes) -> Self

Converts to this type from the input type.
Source§

impl From<EdgeTypeSw> for AllowedEdgeTypes

Source§

fn from(sw: EdgeTypeSw) -> Self

Converts to this type from the input type.
Source§

impl Hash for AllowedEdgeTypes

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 PartialEq for AllowedEdgeTypes

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for AllowedEdgeTypes

Source§

impl TryFrom<u32> for AllowedEdgeTypes

Source§

fn try_from(raw: igraph_edge_type_sw_t) -> Result<Self>

Accepts exactly the four valid flag combinations; any other bit pattern is an ErrorKind::InvalidValue.

Source§

type Error = Error

The type returned in the event of a conversion error.

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