cgv
Loading...
Searching...
No Matches
cgv::math::union_find Struct Reference

A union find data structure. More...

#include <union_find.h>

Public Member Functions

 union_find (int N)
 N number of all elements.
 
 ~union_find ()
 destructor
 
int num_of_components ()
 number of sets (initially number of all elements)
 
int num_in_set (int x)
 
int first_set ()
 
int next_set (int x)
 
int find (int x)
 return label number of element x
 
void unite (int p, int q)
 unite the set containing p with the set containing q (if p and q are in the same set, nothing is done)
 
bool find (int p, int q)
 check wether p and q are in the same set
 

Public Attributes

int * sz
 
int * id
 
int components
 
int N
 

Detailed Description

A union find data structure.

Definition at line 8 of file union_find.h.

Constructor & Destructor Documentation

◆ union_find()

cgv::math::union_find::union_find ( int  N)
inline

N number of all elements.

Definition at line 16 of file union_find.h.

◆ ~union_find()

cgv::math::union_find::~union_find ( )
inline

destructor

Definition at line 29 of file union_find.h.

Member Function Documentation

◆ find() [1/2]

bool cgv::math::union_find::find ( int  p,
int  q 
)
inline

check wether p and q are in the same set

Definition at line 94 of file union_find.h.

References find().

◆ find() [2/2]

int cgv::math::union_find::find ( int  x)
inline

return label number of element x

Definition at line 70 of file union_find.h.

Referenced by find(), and unite().

◆ first_set()

int cgv::math::union_find::first_set ( )
inline

Definition at line 49 of file union_find.h.

◆ next_set()

int cgv::math::union_find::next_set ( int  x)
inline

Definition at line 57 of file union_find.h.

◆ num_in_set()

int cgv::math::union_find::num_in_set ( int  x)
inline

Definition at line 42 of file union_find.h.

◆ num_of_components()

int cgv::math::union_find::num_of_components ( )
inline

number of sets (initially number of all elements)

Definition at line 36 of file union_find.h.

◆ unite()

void cgv::math::union_find::unite ( int  p,
int  q 
)
inline

unite the set containing p with the set containing q (if p and q are in the same set, nothing is done)

Definition at line 83 of file union_find.h.

References find().

Member Data Documentation

◆ components

int cgv::math::union_find::components

Definition at line 12 of file union_find.h.

◆ id

int* cgv::math::union_find::id

Definition at line 11 of file union_find.h.

◆ N

int cgv::math::union_find::N

Definition at line 13 of file union_find.h.

◆ sz

int* cgv::math::union_find::sz

Definition at line 10 of file union_find.h.


The documentation for this struct was generated from the following file: