petgraph::algo::matching

Struct Matching

Source
pub struct Matching<G: GraphBase> { /* private fields */ }
Expand description

Computed matching of the graph.

Implementations§

Source§

impl<G> Matching<G>
where G: NodeIndexable,

Source

pub fn mate(&self, node: G::NodeId) -> Option<G::NodeId>

Gets the matched counterpart of given node, if there is any.

Returns None if the node is not matched or does not exist.

Source

pub fn edges(&self) -> MatchedEdges<'_, G>

Iterates over all edges from the matching.

An edge is represented by its endpoints. The graph is considered undirected and every pair of matched nodes is reported only once.

Source

pub fn nodes(&self) -> MatchedNodes<'_, G>

Iterates over all nodes from the matching.

Source

pub fn contains_edge(&self, a: G::NodeId, b: G::NodeId) -> bool

Returns true if given edge is in the matching, or false otherwise.

If any of the nodes does not exist, false is returned.

Source

pub fn contains_node(&self, node: G::NodeId) -> bool

Returns true if given node is in the matching, or false otherwise.

If the node does not exist, false is returned.

Source

pub fn len(&self) -> usize

Gets the number of matched edges.

Source

pub fn is_empty(&self) -> bool

Returns true if the number of matched edges is 0.

Source§

impl<G> Matching<G>
where G: NodeCount,

Source

pub fn is_perfect(&self) -> bool

Returns true if the matching is perfect.

A matching is perfect if every node in the graph is incident to an edge from the matching.

Auto Trait Implementations§

§

impl<G> Freeze for Matching<G>
where G: Freeze,

§

impl<G> RefUnwindSafe for Matching<G>

§

impl<G> Send for Matching<G>
where G: Send, <G as GraphBase>::NodeId: Send,

§

impl<G> Sync for Matching<G>
where G: Sync, <G as GraphBase>::NodeId: Sync,

§

impl<G> Unpin for Matching<G>
where G: Unpin, <G as GraphBase>::NodeId: Unpin,

§

impl<G> UnwindSafe for Matching<G>

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