Files
fpocket/doc/programmers_guide/html/cluster_8c.html
2017-03-22 23:31:13 +01:00

577 lines
52 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>fpocket: cluster.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<img src="fpocket_logo_small.png" width="545" height="150">
<!-- Generated by Doxygen 1.5.6 -->
<script type="text/javascript">
<!--
function changeDisplayState (e){
var num=this.id.replace(/[^[0-9]/g,'');
var button=this.firstChild;
var sectionDiv=document.getElementById('dynsection'+num);
if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
sectionDiv.style.display='block';
button.src='open.gif';
}else{
sectionDiv.style.display='none';
button.src='closed.gif';
}
}
function initDynSections(){
var divs=document.getElementsByTagName('div');
var sectionCounter=1;
for(var i=0;i<divs.length-1;i++){
if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
var header=divs[i];
var section=divs[i+1];
var button=header.firstChild;
if (button!='IMG'){
divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
button=document.createElement('img');
divs[i].insertBefore(button,divs[i].firstChild);
}
header.style.cursor='pointer';
header.onclick=changeDisplayState;
header.id='dynheader'+sectionCounter;
button.src='closed.gif';
section.id='dynsection'+sectionCounter;
section.style.display='none';
section.style.marginLeft='14px';
sectionCounter++;
}
}
}
window.onload = initDynSections;
-->
</script>
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>cluster.c File Reference</h1><code>#include &quot;<a class="el" href="cluster_8h-source.html">../headers/cluster.h</a>&quot;</code><br>
<p>
<a href="cluster_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="cluster_8c.html#95eaf8237e7a3717a324867a22353b0f">pck_final_clust</a> (<a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *pockets, <a class="el" href="structs__fparams.html">s_fparams</a> *params, <a class="el" href="structs__pdb.html">s_pdb</a> *pdb, <a class="el" href="structs__pdb.html">s_pdb</a> *pdb_w_lig)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="cluster_8c.html#7b27580e1525a01fa58d6b542fcadade">comp_pocket</a> (const void *el1, const void *el2)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="cluster_8c.html#61a16430be8801cb5ea0a0689b99bd10">pck_ml_clust</a> (<a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *pockets, <a class="el" href="structs__fparams.html">s_fparams</a> *params)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="cluster_8c.html#d61fbdd981fbf690824b6892877a49a5">pck_ml_clust_test</a> (<a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *pockets, <a class="el" href="structs__fparams.html">s_fparams</a> *params)</td></tr>
</table>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="7b27580e1525a01fa58d6b542fcadade"></a><!-- doxytag: member="cluster.c::comp_pocket" ref="7b27580e1525a01fa58d6b542fcadade" args="(const void *el1, const void *el2)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int comp_pocket </td>
<td>(</td>
<td class="paramtype">const void *&nbsp;</td>
<td class="paramname"> <em>el1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const void *&nbsp;</td>
<td class="paramname"> <em>el2</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="cluster_8c-source.html#l00255">255</a> of file <a class="el" href="cluster_8c-source.html">cluster.c</a>.</p>
<p>References <a class="el" href="cluster_8h-source.html#l00051">s_sorted_pocket_list::dist</a>.</p>
<p>Referenced by <a class="el" href="cluster_8c-source.html#l00070">pck_final_clust()</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00256"></a>00256 {
<a name="l00257"></a>00257
<a name="l00258"></a>00258 <a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *ia = (<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *)el1;
<a name="l00259"></a>00259 <a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *ib = (<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *)el2;
<a name="l00260"></a>00260
<a name="l00261"></a>00261 <span class="comment">//if (ia-&gt;dist&lt;0.0)printf("dist %f\n",((s_sorted_pocket_list *)el1)-&gt;dist);</span>
<a name="l00262"></a>00262 <span class="keywordflow">if</span> (ia-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a> &lt; ib-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a>) <span class="keywordflow">return</span> -1;
<a name="l00263"></a>00263 <span class="keywordflow">if</span> (ia-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a> == ib-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a>) <span class="keywordflow">return</span> 0;
<a name="l00264"></a>00264 <span class="keywordflow">if</span> (ia-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a> &gt; ib-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a>) <span class="keywordflow">return</span> 1;
<a name="l00265"></a>00265 <span class="keywordflow">return</span> 0;
<a name="l00266"></a>00266 }
</pre></div>
<p>
</div>
</div><p>
<a class="anchor" name="95eaf8237e7a3717a324867a22353b0f"></a><!-- doxytag: member="cluster.c::pck_final_clust" ref="95eaf8237e7a3717a324867a22353b0f" args="(c_lst_pockets *pockets, s_fparams *params, s_pdb *pdb, s_pdb *pdb_w_lig)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pck_final_clust </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *&nbsp;</td>
<td class="paramname"> <em>pockets</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structs__fparams.html">s_fparams</a> *&nbsp;</td>
<td class="paramname"> <em>params</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structs__pdb.html">s_pdb</a> *&nbsp;</td>
<td class="paramname"> <em>pdb</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structs__pdb.html">s_pdb</a> *&nbsp;</td>
<td class="paramname"> <em>pdb_w_lig</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<p>Definition at line <a class="el" href="cluster_8c-source.html#l00070">70</a> of file <a class="el" href="cluster_8c-source.html">cluster.c</a>.</p>
<p>References <a class="el" href="descriptors_8h-source.html#l00058">s_desc::as_density</a>, <a class="el" href="cluster_8c-source.html#l00255">comp_pocket()</a>, <a class="el" href="cluster_8h-source.html#l00051">s_sorted_pocket_list::dist</a>, <a class="el" href="calc_8c-source.html#l00075">dist()</a>, <a class="el" href="voronoi__lst_8h-source.html#l00064">c_lst_vertices::first</a>, <a class="el" href="pocket_8h-source.html#l00089">c_lst_pockets::first</a>, <a class="el" href="pocket_8c-source.html#l01061">mergePockets()</a>, <a class="el" href="memhandler_8c-source.html#l00121">my_malloc()</a>, <a class="el" href="pocket_8h-source.html#l00092">c_lst_pockets::n_pockets</a>, <a class="el" href="descriptors_8h-source.html#l00095">s_desc::nb_asph</a>, <a class="el" href="voronoi__lst_8h-source.html#l00056">node_vertice::next</a>, <a class="el" href="pocket_8h-source.html#l00080">node_pocket::next</a>, <a class="el" href="pocket_8h-source.html#l00061">s_pocket::pdesc</a>, <a class="el" href="cluster_8h-source.html#l00049">s_sorted_pocket_list::pid1</a>, <a class="el" href="cluster_8h-source.html#l00050">s_sorted_pocket_list::pid2</a>, <a class="el" href="pocket_8h-source.html#l00082">node_pocket::pocket</a>, <a class="el" href="pocket_8c-source.html#l00582">set_pockets_descriptors()</a>, <a class="el" href="fparams_8h-source.html#l00150">s_fparams::sl_clust_max_dist</a>, <a class="el" href="pocket_8h-source.html#l00063">s_pocket::v_lst</a>, <a class="el" href="voronoi__lst_8h-source.html#l00058">node_vertice::vertice</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::x</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::y</a>, and <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::z</a>.</p>
<p>Referenced by <a class="el" href="fpocket_8c-source.html#l00082">search_pocket()</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00071"></a>00071 {
<a name="l00072"></a>00072 <a class="code" href="structnode__pocket.html">node_pocket</a> *pcur = NULL,
<a name="l00073"></a>00073 *pnext = NULL ,
<a name="l00074"></a>00074 *curMobilePocket = NULL ;
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <a class="code" href="structnode__vertice.html">node_vertice</a> *vcur = NULL ;
<a name="l00077"></a>00077 <a class="code" href="structnode__vertice.html">node_vertice</a> *curMobileVertice = NULL ;
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <a class="code" href="structs__vvertice.html">s_vvertice</a> *vvcur = NULL,
<a name="l00080"></a>00080 *mvvcur = NULL ;
<a name="l00081"></a>00081 <span class="keywordtype">float</span> vcurx,
<a name="l00082"></a>00082 vcury,
<a name="l00083"></a>00083 vcurz ;
<a name="l00084"></a>00084 <span class="keywordtype">float</span> curdist;
<a name="l00085"></a>00085 <span class="keywordtype">float</span> curasphdens,dens1,dens2;
<a name="l00086"></a>00086 <span class="keywordtype">float</span> **dmat; <span class="comment">/*distance matrix*/</span>
<a name="l00087"></a>00087 <span class="keywordtype">size_t</span> i,j;
<a name="l00088"></a>00088 dmat=(<span class="keywordtype">float</span> **)malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">float</span> *)*pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>);
<a name="l00089"></a>00089 <span class="keywordflow">for</span>(i=0;i&lt;pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>;i++) {
<a name="l00090"></a>00090 dmat[i]=(<span class="keywordtype">float</span> *) malloc(<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>)*pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>);
<a name="l00091"></a>00091 <span class="keywordflow">for</span>(j=0;j&lt;pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>;j++) dmat[i][j]=0.0;
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="comment">/* Flag to know if two clusters are next to each other by single linkage</span>
<a name="l00095"></a>00095 <span class="comment"> * clustering...or not */</span>
<a name="l00096"></a>00096 <span class="keywordtype">int</span> nflag ;
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordflow">if</span>(!pockets) {
<a name="l00099"></a>00099 fprintf(stderr, <span class="stringliteral">"! Incorrect argument during Multiple Linkage Clustering.\n"</span>) ;
<a name="l00100"></a>00100 return ;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <span class="comment">/* Set the first pocket */</span>
<a name="l00104"></a>00104 <a class="code" href="pocket_8c.html#0d15b57b768bd36ef45419f0473217f6">set_pockets_descriptors</a>(pockets,pdb,params,pdb_w_lig);
<a name="l00105"></a>00105 pcur = pockets-&gt;<a class="code" href="structc__lst__pockets.html#cf82eb35ce757228759a9af7675f5ad9">first</a> ;
<a name="l00106"></a>00106 <span class="comment">//fprintf(stdout,"\nHaving %d comparisons\n",pockets-&gt;n_pockets*pockets-&gt;n_pockets);</span>
<a name="l00107"></a>00107 i=0;
<a name="l00108"></a>00108 <span class="keywordtype">size_t</span> n_slist=0;
<a name="l00109"></a>00109 <span class="keywordflow">while</span>(pcur) {
<a name="l00110"></a>00110 j=i+1;
<a name="l00111"></a>00111 <span class="comment">/* Set the second pocket */</span>
<a name="l00112"></a>00112 curMobilePocket = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00113"></a>00113 <span class="keywordflow">while</span>(curMobilePocket) {
<a name="l00114"></a>00114 curdist=0.0;
<a name="l00115"></a>00115
<a name="l00116"></a>00116 nflag = 0 ;
<a name="l00117"></a>00117 <span class="comment">/* Set the first vertice/alpha sphere center of the first pocket */</span>
<a name="l00118"></a>00118 vcur = pcur-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#cf07f539404d23c1956373f8c93a4fcc">v_lst</a>-&gt;<a class="code" href="structc__lst__vertices.html#72562067d308bcfcf32605e112e30c1a">first</a> ;
<a name="l00119"></a>00119 <span class="keywordflow">while</span>(vcur){
<a name="l00120"></a>00120 <span class="comment">/* Set the first vertice/alpha sphere center of the second pocket */</span>
<a name="l00121"></a>00121 curMobileVertice = curMobilePocket-&gt;pocket-&gt;v_lst-&gt;first ;
<a name="l00122"></a>00122 vvcur = vcur-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00123"></a>00123 vcurx = vvcur-&gt;<a class="code" href="structs__vvertice.html#017f9695c923d87d851231bf13967b22">x</a> ;
<a name="l00124"></a>00124 vcury = vvcur-&gt;<a class="code" href="structs__vvertice.html#250642d688398e4186819f63d54247bc">y</a> ;
<a name="l00125"></a>00125 vcurz = vvcur-&gt;<a class="code" href="structs__vvertice.html#3e03d11fd3b1d0ffb623481fa1b497b6">z</a> ;
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="comment">/* Double loop for vertices -&gt; if not near */</span>
<a name="l00128"></a>00128 <span class="keywordflow">while</span>(curMobileVertice){
<a name="l00129"></a>00129 mvvcur = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00130"></a>00130 <span class="keywordflow">if</span>(<a class="code" href="calc_8c.html#615f3353fc9ccc88069adb4000b21e73">dist</a>(vcurx, vcury, vcurz, mvvcur-&gt;x, mvvcur-&gt;y, mvvcur-&gt;z)&lt;params-&gt;<a class="code" href="structs__fparams.html#71691bbfb98d90e12ca8cb3c79e2688c">sl_clust_max_dist</a>) curdist-=1.0;
<a name="l00131"></a>00131 curMobileVertice = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a>;
<a name="l00132"></a>00132 }
<a name="l00133"></a>00133 vcur = vcur-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135
<a name="l00136"></a>00136 pnext = curMobilePocket-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00137"></a>00137 <span class="comment">/* If the distance flag has counted enough occurences of near neighbours, merge pockets*/</span>
<a name="l00138"></a>00138 <span class="comment">/* If they are next to each other, merge them */</span>
<a name="l00139"></a>00139 <span class="comment">//mergePockets(pcur,curMobilePocket,pockets);</span>
<a name="l00140"></a>00140 <span class="comment">//fprintf(stdout,"\ni %d j %d\n",i,j),</span>
<a name="l00141"></a>00141
<a name="l00142"></a>00142 dens1=pcur-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#2aeb19cfc5f53e2d22f1a2065ede1010">as_density</a>;
<a name="l00143"></a>00143 dens1=((isnan(dens1)) ? 0.0 : dens1);
<a name="l00144"></a>00144
<a name="l00145"></a>00145 dens2=curMobilePocket-&gt;pocket-&gt;pdesc-&gt;as_density;
<a name="l00146"></a>00146 dens2=((isnan(dens2)) ? 0.0 : dens2);
<a name="l00147"></a>00147 curasphdens=0.01*(dens1-dens2)*(dens1-dens2);
<a name="l00148"></a>00148 curasphdens+=(exp(0.1*dens1)+exp(0.1*dens2))/2.0-1.0;
<a name="l00149"></a>00149 <span class="comment">//curasphdens=0.0;</span>
<a name="l00150"></a>00150 dmat[i][j]=curdist;
<a name="l00151"></a>00151 dmat[j][i]=curdist;
<a name="l00152"></a>00152 curMobilePocket = pnext ;
<a name="l00153"></a>00153 n_slist++;
<a name="l00154"></a>00154 j++;
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156 pcur = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00157"></a>00157 i++;
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159
<a name="l00160"></a>00160 <span class="comment">/* Now we have to merge nearby pockets without loosing track*/</span>
<a name="l00161"></a>00161
<a name="l00162"></a>00162 <span class="comment">/*create a chained list with track on */</span>
<a name="l00163"></a>00163 n_slist=((pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>*pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>)-pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>)/2;
<a name="l00164"></a>00164 <a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *slist=NULL;
<a name="l00165"></a>00165 slist=(<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *)<a class="code" href="memhandler_8c.html#52d7260a38c396cb2dd1dd7abcfd61cb">my_malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a>)*n_slist);
<a name="l00166"></a>00166 <span class="comment">//s_sorted_pocket_list slist[n_slist];</span>
<a name="l00167"></a>00167 <span class="keywordflow">for</span>(i=0;i&lt;n_slist;i++) slist[i].<a class="code" href="calc_8c.html#615f3353fc9ccc88069adb4000b21e73">dist</a>=0.0;
<a name="l00168"></a>00168 <span class="comment">//for(i=0;i&lt;n_slist;i++)slist[i]=(s_sorted_pocket_list *)my_malloc(sizeof(s_sorted_pocket_list));</span>
<a name="l00169"></a>00169 <a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a> *el=<a class="code" href="memhandler_8c.html#52d7260a38c396cb2dd1dd7abcfd61cb">my_malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a>));
<a name="l00170"></a>00170 <span class="comment">// pcur=pockets-&gt;first;</span>
<a name="l00171"></a>00171
<a name="l00172"></a>00172
<a name="l00173"></a>00173 <span class="keywordtype">int</span> c=0;
<a name="l00174"></a>00174 <span class="keywordflow">for</span>(i=0;i&lt;pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>-1;i++){
<a name="l00175"></a>00175 <span class="comment">//curMobilePocket=pcur-&gt;next;</span>
<a name="l00176"></a>00176 <span class="keywordflow">for</span>(j=i+1;j&lt;pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>;j++){
<a name="l00177"></a>00177
<a name="l00178"></a>00178 el-&gt;<a class="code" href="structs__sorted__pocket__list.html#1b71f96549a50aa6ba203a7c1feea571">dist</a>=dmat[i][j];
<a name="l00179"></a>00179 memcpy(&amp;(slist[c].<a class="code" href="calc_8c.html#615f3353fc9ccc88069adb4000b21e73">dist</a>),&amp;(dmat[i][j]),<span class="keyword">sizeof</span>(<span class="keywordtype">float</span>));
<a name="l00180"></a>00180 <span class="comment">//slist[i+j-1].dist=dmat[i][j];</span>
<a name="l00181"></a>00181 slist[c].<a class="code" href="structs__sorted__pocket__list.html#5facfd99852a742f2724c935afb62a9b">pid1</a>=i;
<a name="l00182"></a>00182 slist[c].<a class="code" href="structs__sorted__pocket__list.html#fc9c4671165c78b6742e88a208a9c93d">pid2</a>=j;
<a name="l00183"></a>00183 <span class="comment">//if(i==173 &amp;&amp; j==299)fprintf(stdout,"\ncurdist %d %d %f %f\n",j+i-1, n_slist,dmat[i][j], slist[j+i-1].dist);</span>
<a name="l00184"></a>00184 <span class="comment">//fprintf(stdout,"%f %d %d\n",slist[c].dist,slist[c].pid1,slist[c].pid2);</span>
<a name="l00185"></a>00185 c++;
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 <span class="comment">// pcur=pcur-&gt;next;</span>
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 <span class="comment">//for(i=0;i&lt;n_slist;i++) if(slist[i].dist&lt;-480.0)fprintf(stdout,"%f %d %d\n",slist[i].dist,slist[i].pid1,slist[i].pid2);</span>
<a name="l00190"></a>00190 <span class="comment">//fflush(stdout);</span>
<a name="l00191"></a>00191 qsort((<span class="keywordtype">void</span> *)slist,n_slist,<span class="keyword">sizeof</span>(<a class="code" href="structs__sorted__pocket__list.html">s_sorted_pocket_list</a>),<a class="code" href="cluster_8c.html#7b27580e1525a01fa58d6b542fcadade">comp_pocket</a>);
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="comment">//for(i=0;i&lt;n_slist;i++) fprintf(stdout,"%f %d %d\n",slist[i].dist,slist[i].pid1,slist[i].pid2);</span>
<a name="l00194"></a>00194 <span class="comment">/*TODO : debug here there are still some neighbours with nan pid's after the qsort*/</span>
<a name="l00195"></a>00195 i=0;
<a name="l00196"></a>00196
<a name="l00197"></a>00197 <span class="comment">/*create a tmp pocket list for updating pointers*/</span>
<a name="l00198"></a>00198 <a class="code" href="structnode__pocket.html">node_pocket</a> **pock_list=<a class="code" href="memhandler_8c.html#52d7260a38c396cb2dd1dd7abcfd61cb">my_malloc</a>(<span class="keyword">sizeof</span>(<a class="code" href="structnode__pocket.html">node_pocket</a> *)*pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>);
<a name="l00199"></a>00199 pcur=pockets-&gt;<a class="code" href="structc__lst__pockets.html#cf82eb35ce757228759a9af7675f5ad9">first</a>;
<a name="l00200"></a>00200 i=0;
<a name="l00201"></a>00201 <span class="comment">/*get a list of pointers to nodes*/</span>
<a name="l00202"></a>00202 <span class="keywordflow">while</span>(pcur) {
<a name="l00203"></a>00203 pock_list[i]=pcur;
<a name="l00204"></a>00204 pcur=pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a>;
<a name="l00205"></a>00205 i++;
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207
<a name="l00208"></a>00208 <span class="keywordtype">int</span> idx1,idx2;
<a name="l00209"></a>00209 <a class="code" href="structnode__pocket.html">node_pocket</a> *p1,*p2;
<a name="l00210"></a>00210 i=0;
<a name="l00211"></a>00211 <span class="keywordtype">size_t</span> init_n_pockets=pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>;
<a name="l00212"></a>00212
<a name="l00213"></a>00213 <span class="keywordflow">while</span>((slist[i].dist&lt;=-params-&gt;sl_clust_min_nneigh) &amp;&amp; (i&lt;n_slist)){
<a name="l00214"></a>00214 <span class="comment">/*for all nearby pockets merge*/</span>
<a name="l00215"></a>00215 <span class="comment">//fprintf(stdout,"%f\n",slist[i].dist);</span>
<a name="l00216"></a>00216 idx1=slist[i].pid1;
<a name="l00217"></a>00217 idx2=slist[i].pid2;
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <span class="comment">/*fprintf(stdout,"%d %d\n",idx1,idx2);</span>
<a name="l00220"></a>00220 <span class="comment"> fflush(stdout);*/</span>
<a name="l00221"></a>00221 <span class="keywordflow">if</span>(pock_list[idx1]!=pock_list[idx2]){
<a name="l00222"></a>00222 p1=*(pock_list+idx1);
<a name="l00223"></a>00223 p2=*(pock_list+idx2);
<a name="l00224"></a>00224 dens1=((isnan(p1-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#2aeb19cfc5f53e2d22f1a2065ede1010">as_density</a>)) ? 0.0 : p1-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#2aeb19cfc5f53e2d22f1a2065ede1010">as_density</a>)/p1-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#d481d25ff964a6858975b5abfb671412">nb_asph</a>;
<a name="l00225"></a>00225 dens2=((isnan(p2-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#2aeb19cfc5f53e2d22f1a2065ede1010">as_density</a>)) ? 0.0 : p2-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#2aeb19cfc5f53e2d22f1a2065ede1010">as_density</a>)/p2-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#aba02d3ca1a41adf62ad69884c85fed5">pdesc</a>-&gt;<a class="code" href="structs__desc.html#d481d25ff964a6858975b5abfb671412">nb_asph</a>;
<a name="l00226"></a>00226 <span class="comment">//printf("%f vs %f\n",dens1/p1-&gt;pocket-&gt;pdesc-&gt;nb_asph, dens2/p1-&gt;pocket-&gt;pdesc-&gt;nb_asph);</span>
<a name="l00227"></a>00227 <span class="keywordflow">if</span>(dens1 &lt; 0.1 &amp;&amp; dens2 &lt; 0.1){
<a name="l00228"></a>00228 <span class="keywordflow">for</span>(j=0;j&lt;init_n_pockets;j++){
<a name="l00229"></a>00229 <span class="keywordflow">if</span>(pock_list[j]==p2){ <span class="comment">//j!=idx2 &amp;&amp;</span>
<a name="l00230"></a>00230 pock_list[j]=p1;
<a name="l00231"></a>00231 <span class="comment">//fprintf(stdout,"update %d to %d\n",j, idx1);</span>
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234
<a name="l00235"></a>00235 <a class="code" href="pocket_8c.html#3973897d1abc3a6fb2af35ec0ba8746a">mergePockets</a>(p1,p2,pockets);
<a name="l00236"></a>00236 pock_list[idx2]=p1;
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239 i++;
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241
<a name="l00242"></a>00242 <span class="comment">//for(i=0;i&lt;pockets-&gt;n_pockets-1;i++){</span>
<a name="l00243"></a>00243 <span class="comment">//fprintf(stdout,"dist %d vs %d = %f\n",slist[i].p1-&gt;pocket-&gt;rank,slist[i].p2-&gt;pocket-&gt;rank,slist[i].dist);</span>
<a name="l00244"></a>00244 <span class="comment">//}</span>
<a name="l00245"></a>00245
<a name="l00246"></a>00246 <span class="comment">/*free dmat*/</span>
<a name="l00247"></a>00247 <span class="keywordflow">for</span>(i=0;i&lt;pockets-&gt;<a class="code" href="structc__lst__pockets.html#c3a6d72365261579a557746bfc96aec3">n_pockets</a>;i++) free(dmat[i]);
<a name="l00248"></a>00248 free(dmat);
<a name="l00249"></a>00249
<a name="l00250"></a>00250 }
</pre></div>
<p>
</div>
</div><p>
<a class="anchor" name="61a16430be8801cb5ea0a0689b99bd10"></a><!-- doxytag: member="cluster.c::pck_ml_clust" ref="61a16430be8801cb5ea0a0689b99bd10" args="(c_lst_pockets *pockets, s_fparams *params)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pck_ml_clust </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *&nbsp;</td>
<td class="paramname"> <em>pockets</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structs__fparams.html">s_fparams</a> *&nbsp;</td>
<td class="paramname"> <em>params</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
## FONCTION: void <a class="el" href="cluster_8h.html#61a16430be8801cb5ea0a0689b99bd10">pck_ml_clust(c_lst_pockets *pockets, s_fparams *params)</a><p>
## SPECIFICATION: This function will apply a mutliple linkage clustering algorithm on the given list of pockets. Considering two pockets, if params-&gt;ml_clust_min_nneigh alpha spheres are separated by a distance lower than params-&gt;ml_clust_max_dist, then merge the two pockets.<p>
## PARAMETRES: @ <a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *pockets : The list of pockets @ <a class="el" href="structs__fparams.html">s_fparams</a> *params : Parameters of the program, including single linkage parameters<p>
## RETURN: void
<p>Definition at line <a class="el" href="cluster_8c-source.html#l00290">290</a> of file <a class="el" href="cluster_8c-source.html">cluster.c</a>.</p>
<p>References <a class="el" href="calc_8c-source.html#l00075">dist()</a>, <a class="el" href="voronoi__lst_8h-source.html#l00064">c_lst_vertices::first</a>, <a class="el" href="pocket_8h-source.html#l00089">c_lst_pockets::first</a>, <a class="el" href="pocket_8c-source.html#l01061">mergePockets()</a>, <a class="el" href="voronoi__lst_8h-source.html#l00056">node_vertice::next</a>, <a class="el" href="pocket_8h-source.html#l00080">node_pocket::next</a>, <a class="el" href="pocket_8h-source.html#l00082">node_pocket::pocket</a>, <a class="el" href="fparams_8h-source.html#l00150">s_fparams::sl_clust_max_dist</a>, <a class="el" href="fparams_8h-source.html#l00141">s_fparams::sl_clust_min_nneigh</a>, <a class="el" href="pocket_8h-source.html#l00063">s_pocket::v_lst</a>, <a class="el" href="voronoi__lst_8h-source.html#l00058">node_vertice::vertice</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::x</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::y</a>, and <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::z</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00291"></a>00291 {
<a name="l00292"></a>00292 <a class="code" href="structnode__pocket.html">node_pocket</a> *pcur = NULL,
<a name="l00293"></a>00293 *pnext = NULL ,
<a name="l00294"></a>00294 *curMobilePocket = NULL ;
<a name="l00295"></a>00295
<a name="l00296"></a>00296 <a class="code" href="structnode__vertice.html">node_vertice</a> *vcur = NULL ;
<a name="l00297"></a>00297 <a class="code" href="structnode__vertice.html">node_vertice</a> *curMobileVertice = NULL ;
<a name="l00298"></a>00298
<a name="l00299"></a>00299 <a class="code" href="structs__vvertice.html">s_vvertice</a> *vvcur = NULL,
<a name="l00300"></a>00300 *mvvcur = NULL ;
<a name="l00301"></a>00301 <span class="keywordtype">float</span> vcurx,
<a name="l00302"></a>00302 vcury,
<a name="l00303"></a>00303 vcurz ;
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <span class="comment">/* Flag to know if two clusters are next to each other by single linkage</span>
<a name="l00306"></a>00306 <span class="comment"> * clustering...or not */</span>
<a name="l00307"></a>00307 <span class="keywordtype">int</span> nflag ;
<a name="l00308"></a>00308
<a name="l00309"></a>00309 <span class="keywordflow">if</span>(!pockets) {
<a name="l00310"></a>00310 fprintf(stderr, <span class="stringliteral">"! Incorrect argument during Single Linkage Clustering.\n"</span>) ;
<a name="l00311"></a>00311 return ;
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313
<a name="l00314"></a>00314 <span class="comment">/* Set the first pocket */</span>
<a name="l00315"></a>00315 pcur = pockets-&gt;<a class="code" href="structc__lst__pockets.html#cf82eb35ce757228759a9af7675f5ad9">first</a> ;
<a name="l00316"></a>00316 <span class="keywordflow">while</span>(pcur) {
<a name="l00317"></a>00317 <span class="comment">/* Set the second pocket */</span>
<a name="l00318"></a>00318 curMobilePocket = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00319"></a>00319 <span class="keywordflow">while</span>(curMobilePocket) {
<a name="l00320"></a>00320 nflag = 0 ;
<a name="l00321"></a>00321 <span class="comment">/* Set the first vertice/alpha sphere center of the first pocket */</span>
<a name="l00322"></a>00322 vcur = pcur-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#cf07f539404d23c1956373f8c93a4fcc">v_lst</a>-&gt;<a class="code" href="structc__lst__vertices.html#72562067d308bcfcf32605e112e30c1a">first</a> ;
<a name="l00323"></a>00323 <span class="keywordflow">while</span>(vcur &amp;&amp; nflag &lt;= params-&gt;sl_clust_min_nneigh){
<a name="l00324"></a>00324 <span class="comment">/* Set the first vertice/alpha sphere center of the second pocket */</span>
<a name="l00325"></a>00325 curMobileVertice = curMobilePocket-&gt;pocket-&gt;v_lst-&gt;first ;
<a name="l00326"></a>00326 vvcur = vcur-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00327"></a>00327 vcurx = vvcur-&gt;<a class="code" href="structs__vvertice.html#017f9695c923d87d851231bf13967b22">x</a> ;
<a name="l00328"></a>00328 vcury = vvcur-&gt;<a class="code" href="structs__vvertice.html#250642d688398e4186819f63d54247bc">y</a> ;
<a name="l00329"></a>00329 vcurz = vvcur-&gt;<a class="code" href="structs__vvertice.html#3e03d11fd3b1d0ffb623481fa1b497b6">z</a> ;
<a name="l00330"></a>00330
<a name="l00331"></a>00331 <span class="comment">/* Double loop for vertices -&gt; if not near */</span>
<a name="l00332"></a>00332 <span class="keywordflow">while</span>(curMobileVertice &amp;&amp; nflag &lt;= params-&gt;sl_clust_min_nneigh){
<a name="l00333"></a>00333 mvvcur = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00334"></a>00334 <span class="keywordflow">if</span>(<a class="code" href="calc_8c.html#615f3353fc9ccc88069adb4000b21e73">dist</a>(vcurx, vcury, vcurz, mvvcur-&gt;x, mvvcur-&gt;y, mvvcur-&gt;z)
<a name="l00335"></a>00335 &lt; params-&gt;<a class="code" href="structs__fparams.html#71691bbfb98d90e12ca8cb3c79e2688c">sl_clust_max_dist</a>) {
<a name="l00336"></a>00336 <span class="comment">/*if beneath the clustering max distance, increment the distance flag*/</span>
<a name="l00337"></a>00337 nflag++;
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339 curMobileVertice = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a>;
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341 vcur = vcur-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343
<a name="l00344"></a>00344 pnext = curMobilePocket-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00345"></a>00345 <span class="comment">/* If the distance flag has counted enough occurences of near neighbours, merge pockets*/</span>
<a name="l00346"></a>00346 <span class="keywordflow">if</span>(nflag &gt;= params-&gt;<a class="code" href="structs__fparams.html#b23279857aaf7861b452cd2bf463f624">sl_clust_min_nneigh</a>) {
<a name="l00347"></a>00347 <span class="comment">/* If they are next to each other, merge them */</span>
<a name="l00348"></a>00348 <a class="code" href="pocket_8c.html#3973897d1abc3a6fb2af35ec0ba8746a">mergePockets</a>(pcur,curMobilePocket,pockets);
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350 curMobilePocket = pnext ;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352
<a name="l00353"></a>00353 pcur = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 }
</pre></div>
<p>
</div>
</div><p>
<a class="anchor" name="d61fbdd981fbf690824b6892877a49a5"></a><!-- doxytag: member="cluster.c::pck_ml_clust_test" ref="d61fbdd981fbf690824b6892877a49a5" args="(c_lst_pockets *pockets, s_fparams *params)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void pck_ml_clust_test </td>
<td>(</td>
<td class="paramtype"><a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *&nbsp;</td>
<td class="paramname"> <em>pockets</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype"><a class="el" href="structs__fparams.html">s_fparams</a> *&nbsp;</td>
<td class="paramname"> <em>params</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
## FONCTION: void <a class="el" href="cluster_8h.html#61a16430be8801cb5ea0a0689b99bd10">pck_ml_clust(c_lst_pockets *pockets, s_fparams *params)</a><p>
## SPECIFICATION: This function will apply a mutliple linkage clustering algorithm on the given list of pockets. Considering two pockets, if params-&gt;ml_clust_min_nneigh alpha spheres are separated by a distance lower than params-&gt;ml_clust_max_dist, then merge the two pockets.<p>
## PARAMETRES: @ <a class="el" href="structc__lst__pockets.html">c_lst_pockets</a> *pockets : The list of pockets @ <a class="el" href="structs__fparams.html">s_fparams</a> *params : Parameters of the program, including single linkage parameters<p>
## RETURN: void
<p>Definition at line <a class="el" href="cluster_8c-source.html#l00376">376</a> of file <a class="el" href="cluster_8c-source.html">cluster.c</a>.</p>
<p>References <a class="el" href="calc_8c-source.html#l00075">dist()</a>, <a class="el" href="voronoi__lst_8h-source.html#l00064">c_lst_vertices::first</a>, <a class="el" href="pocket_8h-source.html#l00089">c_lst_pockets::first</a>, <a class="el" href="pocket_8c-source.html#l01061">mergePockets()</a>, <a class="el" href="voronoi__lst_8h-source.html#l00056">node_vertice::next</a>, <a class="el" href="pocket_8h-source.html#l00080">node_pocket::next</a>, <a class="el" href="pocket_8h-source.html#l00082">node_pocket::pocket</a>, <a class="el" href="fparams_8h-source.html#l00150">s_fparams::sl_clust_max_dist</a>, <a class="el" href="fparams_8h-source.html#l00141">s_fparams::sl_clust_min_nneigh</a>, <a class="el" href="pocket_8h-source.html#l00063">s_pocket::v_lst</a>, <a class="el" href="voronoi__lst_8h-source.html#l00058">node_vertice::vertice</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::x</a>, <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::y</a>, and <a class="el" href="voronoi_8h-source.html#l00076">s_vvertice::z</a>.</p>
<div class="fragment"><pre class="fragment"><a name="l00377"></a>00377 {
<a name="l00378"></a>00378 <a class="code" href="structnode__pocket.html">node_pocket</a> *pcur = NULL,
<a name="l00379"></a>00379 *pnext = NULL ,
<a name="l00380"></a>00380 *curMobilePocket = NULL ;
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <a class="code" href="structnode__vertice.html">node_vertice</a> *vcur = NULL ;
<a name="l00383"></a>00383 <a class="code" href="structnode__vertice.html">node_vertice</a> *curMobileVertice = NULL ;
<a name="l00384"></a>00384
<a name="l00385"></a>00385 <a class="code" href="structs__vvertice.html">s_vvertice</a> *vvcur = NULL,
<a name="l00386"></a>00386 *mvvcur = NULL ;
<a name="l00387"></a>00387 <span class="keywordtype">float</span> vcurx,
<a name="l00388"></a>00388 vcury,
<a name="l00389"></a>00389 vcurz ;
<a name="l00390"></a>00390
<a name="l00391"></a>00391 <span class="comment">/* Flag to know if two clusters are next to each other by single linkage</span>
<a name="l00392"></a>00392 <span class="comment"> * clustering...or not */</span>
<a name="l00393"></a>00393 <span class="keywordtype">int</span> nflag,
<a name="l00394"></a>00394 restart = 0;
<a name="l00395"></a>00395
<a name="l00396"></a>00396 <span class="keywordflow">if</span>(!pockets) {
<a name="l00397"></a>00397 fprintf(stderr, <span class="stringliteral">"! Incorrect argument during Single Linkage Clustering.\n"</span>) ;
<a name="l00398"></a>00398 return ;
<a name="l00399"></a>00399 }
<a name="l00400"></a>00400 printf(<span class="stringliteral">"ML starting\n"</span>) ;
<a name="l00401"></a>00401 <span class="comment">/* Set the first pocket */</span>
<a name="l00402"></a>00402 pcur = pockets-&gt;<a class="code" href="structc__lst__pockets.html#cf82eb35ce757228759a9af7675f5ad9">first</a> ;
<a name="l00403"></a>00403 <span class="keywordflow">while</span>(pcur) {
<a name="l00404"></a>00404 <span class="comment">/* Set the second pocket */</span>
<a name="l00405"></a>00405 curMobilePocket = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00406"></a>00406 <span class="keywordflow">while</span>(curMobilePocket) {
<a name="l00407"></a>00407 nflag = 0 ;
<a name="l00408"></a>00408 <span class="comment">/* Set the first vertice/alpha sphere center of the first pocket */</span>
<a name="l00409"></a>00409 vcur = pcur-&gt;<a class="code" href="structnode__pocket.html#8dbdbb50f893fa45bba2d8c03aff6553">pocket</a>-&gt;<a class="code" href="structs__pocket.html#cf07f539404d23c1956373f8c93a4fcc">v_lst</a>-&gt;<a class="code" href="structc__lst__vertices.html#72562067d308bcfcf32605e112e30c1a">first</a> ;
<a name="l00410"></a>00410 <span class="keywordflow">while</span>(vcur &amp;&amp; nflag &lt;= params-&gt;sl_clust_min_nneigh){
<a name="l00411"></a>00411 <span class="comment">/* Set the first vertice/alpha sphere center of the second pocket */</span>
<a name="l00412"></a>00412 curMobileVertice = curMobilePocket-&gt;pocket-&gt;v_lst-&gt;first ;
<a name="l00413"></a>00413 vvcur = vcur-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00414"></a>00414 vcurx = vvcur-&gt;<a class="code" href="structs__vvertice.html#017f9695c923d87d851231bf13967b22">x</a> ;
<a name="l00415"></a>00415 vcury = vvcur-&gt;<a class="code" href="structs__vvertice.html#250642d688398e4186819f63d54247bc">y</a> ;
<a name="l00416"></a>00416 vcurz = vvcur-&gt;<a class="code" href="structs__vvertice.html#3e03d11fd3b1d0ffb623481fa1b497b6">z</a> ;
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <span class="comment">/* Double loop for vertices -&gt; if not near */</span>
<a name="l00419"></a>00419 <span class="keywordflow">while</span>(curMobileVertice &amp;&amp; nflag &lt;= params-&gt;sl_clust_min_nneigh){
<a name="l00420"></a>00420 mvvcur = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#7e7063f6403dfd8f0a8f83462e27729b">vertice</a> ;
<a name="l00421"></a>00421 <span class="keywordflow">if</span>(<a class="code" href="calc_8c.html#615f3353fc9ccc88069adb4000b21e73">dist</a>(vcurx, vcury, vcurz, mvvcur-&gt;x, mvvcur-&gt;y, mvvcur-&gt;z)
<a name="l00422"></a>00422 &lt; params-&gt;<a class="code" href="structs__fparams.html#71691bbfb98d90e12ca8cb3c79e2688c">sl_clust_max_dist</a>) {
<a name="l00423"></a>00423 <span class="comment">/*if beneath the clustering max distance, increment the distance flag*/</span>
<a name="l00424"></a>00424 nflag++;
<a name="l00425"></a>00425 break ; <span class="comment">/* Ensure that at least N vertice in one of the</span>
<a name="l00426"></a>00426 <span class="comment"> two pockets have N vertice at a distance</span>
<a name="l00427"></a>00427 <span class="comment"> &lt;= SL_MAX_DST */</span>
<a name="l00428"></a>00428 }
<a name="l00429"></a>00429 curMobileVertice = curMobileVertice-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a>;
<a name="l00430"></a>00430 }
<a name="l00431"></a>00431 vcur = vcur-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00432"></a>00432 }
<a name="l00433"></a>00433
<a name="l00434"></a>00434 pnext = curMobilePocket-&gt;<a class="code" href="structnode__vertice.html#61b34ff349d05cc65a4d8b9e2c77ff3e">next</a> ;
<a name="l00435"></a>00435 <span class="comment">/* If the distance flag has counted enough occurences of near neighbours, merge pockets*/</span>
<a name="l00436"></a>00436 <span class="keywordflow">if</span>(nflag &gt;= params-&gt;<a class="code" href="structs__fparams.html#b23279857aaf7861b452cd2bf463f624">sl_clust_min_nneigh</a>) {
<a name="l00437"></a>00437 <span class="comment">/* If they are next to each other, merge them */</span>
<a name="l00438"></a>00438 <a class="code" href="pocket_8c.html#3973897d1abc3a6fb2af35ec0ba8746a">mergePockets</a>(pcur,curMobilePocket,pockets);
<a name="l00439"></a>00439 restart = 1 ; printf(<span class="stringliteral">"Merging\n"</span>) ;
<a name="l00440"></a>00440 break ;
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 curMobilePocket = pnext ;
<a name="l00443"></a>00443 }
<a name="l00444"></a>00444
<a name="l00445"></a>00445 <span class="comment">/* Restart the algorithm if two pockets have been merged */</span>
<a name="l00446"></a>00446 <span class="keywordflow">if</span>(restart == 1) {
<a name="l00447"></a>00447 restart = 0 ;
<a name="l00448"></a>00448 pcur = pockets-&gt;<a class="code" href="structc__lst__pockets.html#cf82eb35ce757228759a9af7675f5ad9">first</a> ;
<a name="l00449"></a>00449 }
<a name="l00450"></a>00450 <span class="keywordflow">else</span> pcur = pcur-&gt;<a class="code" href="structnode__pocket.html#a33c910dd9e6996001374199f250267e">next</a> ;
<a name="l00451"></a>00451 }
<a name="l00452"></a>00452 printf(<span class="stringliteral">"ML ending\n"</span>) ;
<a name="l00453"></a>00453 }
</pre></div>
<p>
</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jun 7 16:44:23 2010 for fpocket by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>