From 0652ee2715994b48a9bbfd1132bf0b65ad206289 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Wed, 27 Nov 2013 18:46:13 +0000 Subject: [PATCH] commiting all changes. --- src/vertex.c | 41 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 40 insertions(+), 1 deletions(-) diff --git a/src/vertex.c b/src/vertex.c index 38647aa..cd999df 100644 --- a/src/vertex.c +++ b/src/vertex.c @@ -23,7 +23,7 @@ for(i=0;i<N;i++) { vlist->vtx[i]=(ts_vertex *)calloc(1,sizeof(ts_vertex)); vlist->vtx[i]->idx=i; - + vlist->vtx[i]->locked=(ts_uint *)calloc(1,sizeof(ts_vertex)); /* initialize Ylm for spherical hamonics DONE in sh.c */ /* for(i=0;i<l;i++){ vlist->vtx[i]->Ylm[i]=(ts_double **)calloc(2*i+1,sizeof(ts_double *)); @@ -311,3 +311,42 @@ return vlist; } + + + +ts_bool vertex_taint(ts_vertex *vtx, ts_uint level){ + ts_uint i; + (*(vtx->locked))=1; //lock current vertex + if(level==0){ //if we reach last in recursion exit + return TS_SUCCESS; + } + for(i=0; i<vtx->neigh_no; i++){ //else recursive call self with decreased level + vertex_taint(vtx->neigh[i], level-1); + } + return TS_SUCCESS; +} + +ts_bool vertex_untaint(ts_vertex *vtx, ts_uint level){ + (*(vtx->locked))=0; + if(level==0){ + return TS_SUCCESS; + } + ts_uint i; + for(i=0; i<vtx->neigh_no; i++){ + vertex_untaint(vtx->neigh[i], level-1); + } + return TS_SUCCESS; +} + +inline ts_bool vertex_tainted(ts_vertex *vtx, ts_uint level, ts_uint amount){ + if(*(vtx->locked)>amount) return 1; + if(level==0){ + return 0; + } + ts_uint i; + for(i=0; i<vtx->neigh_no;i++){ + if(vertex_tainted(vtx->neigh[i], level-1, amount)) return 1; + } + + return 0; +} -- Gitblit v1.9.3