ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches

The MFSET of section 10.2, the union of disjoint sets. More...

Files

file  ADS/mfset/MFSet.h
 The MFSET of section 10.2, the union of disjoint sets: MFSet( n ) makes the \( n \) components \( \{ 0 \} , \ldots , \{ n - 1 \} \), find( x ) gives the representative of the component of \( x \), and merge( x , y ) joins the components of \( x \) and \( y \), if they are distinct.

Classes

class  ADS::MFSet
 the union of disjoint sets on a forest More...

Functions

template<Graph G>
MFSet ADS::components (const G &g)
 the MFSET of the connected components of an unoriented graph, built by merging the ends of each edge (the cc() of section 10.2.5); its elements are the names \( [ 0 , \mathrm{bound}() ) \) of \( g \), so that a name that is not a node of \( g \), a deleted one, is a component of its own, counted by count()

Detailed description

The MFSET of section 10.2, the union of disjoint sets.

The definitions, the invariants and the costs of the area are in Theory of merge-find sets.

Function documentation

◆ components()

template<Graph G>
MFSet ADS::components ( const G & g)

the MFSET of the connected components of an unoriented graph, built by merging the ends of each edge (the cc() of section 10.2.5); its elements are the names \( [ 0 , \mathrm{bound}() ) \) of \( g \), so that a name that is not a node of \( g \), a deleted one, is a component of its own, counted by count()

In pseudocode (section 10.2.5):

\[\class{pseudocode}{\begin{array}{r@{\quad}l} 1 & \textbf{function}\ \mathrm{components}( G ) \cr 2 & \quad M \gets \mathrm{Mfset}( G.\mathrm{bound}() )\quad \triangleright\ \text{each node alone} \cr 3 & \quad \textbf{foreach}\ \text{edge } ( u , v ) \text{ of } G \ \textbf{do}\ M.\mathrm{merge}( u , v ) \cr 4 & \quad \textbf{return}\ M \end{array}} \]