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: boolWhether self-loops are allowed.
multi: boolWhether multi-edges (parallel edges) are allowed.
Implementations§
Source§impl AllowedEdgeTypes
impl AllowedEdgeTypes
Sourcepub const SIMPLE: Self
pub const SIMPLE: Self
Simple graphs only: neither self-loops nor multi-edges (IGRAPH_SIMPLE_SW).
Sourcepub const LOOPS: Self
pub const LOOPS: Self
Self-loops allowed, but no multi-edges (IGRAPH_LOOPS_SW); at most
one self-loop per vertex.
Sourcepub const ALL: Self
pub const ALL: Self
Both self-loops and multi-edges allowed (IGRAPH_LOOPS_SW | IGRAPH_MULTI_SW).
Sourcepub const fn to_raw(self) -> igraph_edge_type_sw_t
pub const fn to_raw(self) -> igraph_edge_type_sw_t
The raw igraph bit flags.
Trait Implementations§
Source§impl BitOr for AllowedEdgeTypes
impl BitOr for AllowedEdgeTypes
Source§impl BitOr<EdgeTypeSw> for AllowedEdgeTypes
impl BitOr<EdgeTypeSw> for AllowedEdgeTypes
Source§type Output = AllowedEdgeTypes
type Output = AllowedEdgeTypes
| operator.Source§fn bitor(self, rhs: EdgeTypeSw) -> Self
fn bitor(self, rhs: EdgeTypeSw) -> Self
| operation. Read moreSource§impl Clone for AllowedEdgeTypes
impl Clone for AllowedEdgeTypes
Source§fn clone(&self) -> AllowedEdgeTypes
fn clone(&self) -> AllowedEdgeTypes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for AllowedEdgeTypes
Source§impl Debug for AllowedEdgeTypes
impl Debug for AllowedEdgeTypes
Source§impl Default for AllowedEdgeTypes
impl Default for AllowedEdgeTypes
Source§fn default() -> AllowedEdgeTypes
fn default() -> AllowedEdgeTypes
impl Eq for AllowedEdgeTypes
Source§impl From<AllowedEdgeTypes> for igraph_edge_type_sw_t
impl From<AllowedEdgeTypes> for igraph_edge_type_sw_t
Source§fn from(types: AllowedEdgeTypes) -> Self
fn from(types: AllowedEdgeTypes) -> Self
Source§impl From<EdgeTypeSw> for AllowedEdgeTypes
impl From<EdgeTypeSw> for AllowedEdgeTypes
Source§fn from(sw: EdgeTypeSw) -> Self
fn from(sw: EdgeTypeSw) -> Self
Source§impl Hash for AllowedEdgeTypes
impl Hash for AllowedEdgeTypes
Source§impl PartialEq for AllowedEdgeTypes
impl PartialEq for AllowedEdgeTypes
Source§fn eq(&self, other: &AllowedEdgeTypes) -> bool
fn eq(&self, other: &AllowedEdgeTypes) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for AllowedEdgeTypes
Source§impl TryFrom<u32> for AllowedEdgeTypes
impl TryFrom<u32> for AllowedEdgeTypes
Source§fn try_from(raw: igraph_edge_type_sw_t) -> Result<Self>
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.