2020-07-11 07:21:17 +03:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=9" / >
2020-09-03 15:54:15 +03:00
< meta name = "generator" content = "Doxygen 1.8.20" / >
2020-07-11 07:21:17 +03:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > Algorithms_in_C: misc/union_find.c File Reference< / title >
< link href = "../../tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../jquery.js" > < / script >
< script type = "text/javascript" src = "../../dynsections.js" > < / script >
< link href = "../../navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../resize.js" > < / script >
< script type = "text/javascript" src = "../../navtreedata.js" > < / script >
< script type = "text/javascript" src = "../../navtree.js" > < / script >
< link href = "../../search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../search/searchdata.js" > < / script >
< script type = "text/javascript" src = "../../search/search.js" > < / script >
< script type = "text/x-mathjax-config" >
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
< / script >
< script type = "text/javascript" async = "async" src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js" > < / script >
< link href = "../../doxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
< tr style = "height: 56px;" >
< td id = "projectalign" style = "padding-left: 0.5em;" >
< div id = "projectname" > Algorithms_in_C
  < span id = "projectnumber" > 1.0.0< / span >
< / div >
< div id = "projectbrief" > Set of algorithms implemented in C.< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2020-09-03 15:54:15 +03:00
<!-- Generated by Doxygen 1.8.20 -->
2020-07-11 07:21:17 +03:00
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
/* @license-end */
< / script >
< script type = "text/javascript" src = "../../menudata.js" > < / script >
< script type = "text/javascript" src = "../../menu.js" > < / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3& dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('df/df3/union__find_8c.html','../../'); initResizable(); });
/* @license-end */
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
< iframe src = "javascript:void(0)" frameborder = "0"
name="MSearchResults" id="MSearchResults">
< / iframe >
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#define-members" > Macros< / a > |
< a href = "#func-members" > Functions< / a > < / div >
< div class = "headertitle" >
< div class = "title" > union_find.c File Reference< / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
< p > < a href = "https://en.wikipedia.org/wiki/Disjoint-set_data_structure" > Union find< / a > algorithm.
< a href = "#details" > More...< / a > < / p >
< div class = "textblock" > < code > #include < stdio.h> < / code > < br / >
< code > #include < stdlib.h> < / code > < br / >
< / div > < div class = "textblock" > < div class = "dynheader" >
Include dependency graph for union_find.c:< / div >
< div class = "dyncontent" >
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d3/d60/union__find_8c__incl.svg" width = "160" height = "112" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe >
< / div >
< / div >
< / div > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a name = "define-members" > < / a >
Macros< / h2 > < / td > < / tr >
< tr class = "memitem:a0592dba56693fad79136250c11e5a7fe" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "a0592dba56693fad79136250c11e5a7fe" > < / a >
#define  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/df3/union__find_8c.html#a0592dba56693fad79136250c11e5a7fe" > MAX_SIZE< / a >       1000< / td > < / tr >
< tr class = "memdesc:a0592dba56693fad79136250c11e5a7fe" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > maximum number of elements in the set < br / > < / td > < / tr >
< tr class = "separator:a0592dba56693fad79136250c11e5a7fe" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a name = "func-members" > < / a >
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:a3e13b69cce5a1b25ae034798092f3d86" > < td class = "memItemLeft" align = "right" valign = "top" > int  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > find< / a > (int *p, int x)< / td > < / tr >
< tr class = "memdesc:a3e13b69cce5a1b25ae034798092f3d86" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Find index of or value in an array. < a href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:a3e13b69cce5a1b25ae034798092f3d86" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:af2f3ff6d98641f7d3be11f071c97908a" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/df3/union__find_8c.html#af2f3ff6d98641f7d3be11f071c97908a" > join< / a > (int *p, int x, int y)< / td > < / tr >
< tr class = "memdesc:af2f3ff6d98641f7d3be11f071c97908a" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Function to join. < a href = "../../df/df3/union__find_8c.html#af2f3ff6d98641f7d3be11f071c97908a" > More...< / a > < br / > < / td > < / tr >
< tr class = "separator:af2f3ff6d98641f7d3be11f071c97908a" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "ae66f6b31b5ad750f1fe042a706a4e3d4" > < / a >
int  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../df/df3/union__find_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4" > main< / a > ()< / td > < / tr >
< tr class = "memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Main function. < br / > < / td > < / tr >
< tr class = "separator:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 class = "groupheader" > Detailed Description< / h2 >
< div class = "textblock" > < p > < a href = "https://en.wikipedia.org/wiki/Disjoint-set_data_structure" > Union find< / a > algorithm. < / p >
< / div > < h2 class = "groupheader" > Function Documentation< / h2 >
< a id = "a3e13b69cce5a1b25ae034798092f3d86" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a3e13b69cce5a1b25ae034798092f3d86" > ◆ < / a > < / span > find()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > int find < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > p< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > x< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Find index of or value in an array. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > p< / td > < td > array to search and update < / td > < / tr >
< tr > < td class = "paramdir" > < / td > < td class = "paramname" > x< / td > < td > value to search < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > value at the index < code > x< / code > < / dd > < / dl >
< div class = "fragment" > < div class = "line" > < a name = "l00018" > < / a > < span class = "lineno" > 18< / span >   {< / div >
< div class = "line" > < a name = "l00019" > < / a > < span class = "lineno" > 19< / span >   < span class = "keywordflow" > if< / span > (x > = < a class = "code" href = "../../df/df3/union__find_8c.html#a0592dba56693fad79136250c11e5a7fe" > MAX_SIZE< / a > )< / div >
< div class = "line" > < a name = "l00020" > < / a > < span class = "lineno" > 20< / span >   {< / div >
< div class = "line" > < a name = "l00021" > < / a > < span class = "lineno" > 21< / span >   fprintf(stderr, < span class = "stringliteral" > " Out-of bounds value\n" < / span > );< / div >
< div class = "line" > < a name = "l00022" > < / a > < span class = "lineno" > 22< / span >   exit(EXIT_FAILURE);< / div >
< div class = "line" > < a name = "l00023" > < / a > < span class = "lineno" > 23< / span >   }< / div >
< div class = "line" > < a name = "l00024" > < / a > < span class = "lineno" > 24< / span >   < / div >
< div class = "line" > < a name = "l00025" > < / a > < span class = "lineno" > 25< / span >   < span class = "keywordflow" > if< / span > (p[x] == x)< / div >
< div class = "line" > < a name = "l00026" > < / a > < span class = "lineno" > 26< / span >   {< / div >
< div class = "line" > < a name = "l00027" > < / a > < span class = "lineno" > 27< / span >   < span class = "keywordflow" > return< / span > x;< / div >
< div class = "line" > < a name = "l00028" > < / a > < span class = "lineno" > 28< / span >   }< / div >
< div class = "line" > < a name = "l00029" > < / a > < span class = "lineno" > 29< / span >   < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < a name = "l00030" > < / a > < span class = "lineno" > 30< / span >   {< / div >
< div class = "line" > < a name = "l00031" > < / a > < span class = "lineno" > 31< / span >   p[x] = < a class = "code" href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > find< / a > (p, p[x]);< / div >
< div class = "line" > < a name = "l00032" > < / a > < span class = "lineno" > 32< / span >   < span class = "keywordflow" > return< / span > p[x];< / div >
< div class = "line" > < a name = "l00033" > < / a > < span class = "lineno" > 33< / span >   }< / div >
< div class = "line" > < a name = "l00034" > < / a > < span class = "lineno" > 34< / span >   }< / div >
< / div > <!-- fragment -->
< / div >
< / div >
< a id = "af2f3ff6d98641f7d3be11f071c97908a" > < / a >
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#af2f3ff6d98641f7d3be11f071c97908a" > ◆ < / a > < / span > join()< / h2 >
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void join < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > p< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > x< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > y< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Function to join. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > p< / td > < td > array to join in < / td > < / tr >
< tr > < td class = "paramdir" > < / td > < td class = "paramname" > x< / td > < td > value or index to join to < / td > < / tr >
< tr > < td class = "paramdir" > < / td > < td class = "paramname" > y< / td > < td > value or index to join from < / td > < / tr >
< / table >
< / dd >
< / dl >
< div class = "fragment" > < div class = "line" > < a name = "l00042" > < / a > < span class = "lineno" > 42< / span >   { p[< a class = "code" href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > find< / a > (p, x)] = < a class = "code" href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > find< / a > (p, y); }< / div >
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../df/df3/union__find_8c_af2f3ff6d98641f7d3be11f071c97908a_cgraph.svg" width = "144" height = "38" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe >
< / div >
< / div >
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
< div class = "ttc" id = "aunion__find_8c_html_a0592dba56693fad79136250c11e5a7fe" > < div class = "ttname" > < a href = "../../df/df3/union__find_8c.html#a0592dba56693fad79136250c11e5a7fe" > MAX_SIZE< / a > < / div > < div class = "ttdeci" > #define MAX_SIZE< / div > < div class = "ttdoc" > maximum number of elements in the set< / div > < div class = "ttdef" > < b > Definition:< / b > union_find.c:8< / div > < / div >
< div class = "ttc" id = "aunion__find_8c_html_a3e13b69cce5a1b25ae034798092f3d86" > < div class = "ttname" > < a href = "../../df/df3/union__find_8c.html#a3e13b69cce5a1b25ae034798092f3d86" > find< / a > < / div > < div class = "ttdeci" > int find(int *p, int x)< / div > < div class = "ttdoc" > Find index of or value in an array.< / div > < div class = "ttdef" > < b > Definition:< / b > union_find.c:17< / div > < / div >
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
< li class = "navelem" > < a class = "el" href = "../../dir_a52f4d3d586a58b02f3a4ddf0a992157.html" > misc< / a > < / li > < li class = "navelem" > < a class = "el" href = "../../df/df3/union__find_8c.html" > union_find.c< / a > < / li >
2020-09-03 15:54:15 +03:00
< li class = "footer" > Generated by < a href = "http://www.doxygen.org/index.html" > < img class = "footer" src = "../../doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.8.20 < / li >
2020-07-11 07:21:17 +03:00
< / ul >
< / div >
< / body >
< / html >