Struct ConnectivityGraph

Source
pub struct ConnectivityGraph<'a> {
    pub graph: &'a Graph,
    pub cc: Vec<usize>,
    pub vcc: Vec<usize>,
    pub num_cc: usize,
    pub num_vcc: usize,
}
Expand description

Represents the decomposition of a graph into any of its constituent parts:

  • Connected components (CC),
  • Strongly connected components (SCC),
  • 2-edge-connected components (2ECC),
  • 2-vertex-connected components (2VCC)

Multiple-edges and self-loops are correctly handled.

Fields§

§graph: &'a Graph§cc: Vec<usize>

ID of a vertex’s CC, SCC or 2ECC, whichever applies. Range 1 to num_cc.

§vcc: Vec<usize>

ID of an edge’s 2VCC, where applicable. Ranges from 1 to num_vcc.

§num_cc: usize

Total number of CCs, SCCs or 2ECCs, whichever applies.

§num_vcc: usize

Total number of 2VCCs, where applicable.

Implementations§

Source§

impl<'a> ConnectivityGraph<'a>

Source

pub fn new(graph: &'a Graph, is_directed: bool) -> Self

Computes CCs (connected components), SCCs (strongly connected components), 2ECCs (2-edge-connected components), and/or 2VCCs (2-vertex-connected components), depending on the parameter and graph:

  • is_directed == true on directed graph: SCCs in rev-topological order
  • is_directed == true on undirected graph: CCs
  • is_directed == false on undirected graph: 2ECCs and 2VCCs
  • is_directed == false on directed graph: undefined behavior
Source

pub fn two_sat_assign(&self) -> Option<Vec<bool>>

From the directed implication graph corresponding to a 2-SAT clause, finds a satisfying assignment if it exists or returns None otherwise.

Source

pub fn topological_sort(&self) -> Vec<usize>

Gets the vertices of a graph according to a topological order of the strongly connected components. Most often used on DAGs.

Source

pub fn is_cut_vertex(&self, u: usize) -> bool

In an undirected graph, determines whether u is an articulation vertex.

Source

pub fn is_cut_edge(&self, e: usize) -> bool

In an undirected graph, determines whether e is a bridge

Auto Trait Implementations§

§

impl<'a> Freeze for ConnectivityGraph<'a>

§

impl<'a> RefUnwindSafe for ConnectivityGraph<'a>

§

impl<'a> Send for ConnectivityGraph<'a>

§

impl<'a> Sync for ConnectivityGraph<'a>

§

impl<'a> Unpin for ConnectivityGraph<'a>

§

impl<'a> UnwindSafe for ConnectivityGraph<'a>

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.