@Phani bhushan
I attached program.
Given below is a trace of the program
No.of nodes =10
MST Ener=1578959 MSTInterference=4
*Program received signal SIGSEGV, Segmentation fault.*
0x0000000000400e1b in connect (V=0x7fffffffdfe0, i=1, j=6318672, cost=0) at
newEnergy.c:246
246 if (V[j]->ptr==NULL) V[j]->ptr=y;
(gdb) bt
#0 0x0000000000400e1b in connect (V=0x7fffffffdfe0, i=1, j=6318672,
cost=0) at newEnergy.c:246
#1 0x00000000004017b6 in addEdge (V=0x7fffffffdf90, T=0x7fffffffdfe0, i=1,
j=6318672) at newEnergy.c:498
#2 0x00000000004020c3 in localMST (V=0x7fffffffdf90, T=0x7fffffffdfe0,
mm=1578959, ml=0x7fffffffe090, inum=0x7fffffffe0d0,
ani=0x7fffffffe100) at newEnergy.c:699
#3 0x0000000000402960 in main () at newEnergy.c:887
thank you
--
Pushparaj
--
Mailing list guidelines and other related articles: http://lug-iitd.org/Footer
//Interference and Energy minimizing topology
#include <time.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<fcntl.h>
#define N 10
#define CNT 1
#define inf 9999999
#define XMAX 1000
#define YMAX 1000
#define TRUE 1
#define FALSE 0
#define WHITE 0
#define GRAY 1
#define BLACK 2
//#include"theader.c"
//#include"tbheap.c"
//#include"krus2608.c"
//#include"localSearch2608.c"
struct gnode{
long cost;
int label;
//int ic;
struct gnode *next;
};
struct ghead{
struct gnode *ptr;
int color;
int inum;
long pow;
long key;
int pLabel; //parent label
int sLabel; // self label
};
struct bnode{
struct ghead *ver; //pointer to V[i]
int index;
};
struct list{
int label,rep;
struct list *next;
};
struct arc{
int a,b,ic;
struct arc *next;
};
struct point{
int x,y;
};
int Left(int i){
return 2*i;
}
int Right(int i){
return 2*i+1;
}
int Parent(int i){
return i/2;
}
void exchangv(int *x, int *y){
int temp=*x;
*x=*y;
*y=temp;
}
void exchange(struct bnode **x, struct bnode **y){
struct bnode *temp;
temp=*x;
*x=*y;
*y=temp;
}
downHeap(struct bnode *H[], int i){
int l,r,small,size=H[0]->index;
//printf("%d\t",T[0]->key);
l=Left(i);
r=Right(i);
if(l<=size && H[l]->ver->key <H[i]->ver->key)
small=l;
else small=i;
if(r<=size && H[r]->ver->key < H[small]->ver->key)
small=r;
if(small!=i){
//T[i]->index=small;
//T[small]->index=i;
exchange(&H[i],&H[small]);
//updateBT(T[i],T[small]);
//exchangv(&T[i]->index,&T[small]->index);
downHeap(H,small);
}
return;
}
buildMinHeap(struct bnode *H[]){
int i,size=H[0]->index;
for(i=size/2;i>=1;i--)
downHeap(H,i);
return;
}
struct bnode *extractMin(struct bnode *H[]){
int size=H[0]->index;
struct bnode *min;
if(size<1) {printf("error");return (NULL);}
min=H[1];
H[1]=H[size];
H[0]->index=--size;
//exchangv(&H[1]->index,&T[size]->index);
//T[size]->index=1;
downHeap(H,1);
return min;
}
int findIndex(struct ghead *x, struct bnode *H[]){
int i,size;
//printf("%d",N);
//for(i=0;i<N;i++){
// printf("%d:%d\n",T[i+1]->ver->sLabel,x->sLabel);
// }
size=H[0]->index;
for(i=0;i<size;i++){
//printf("%d:%d\n",T[i+1]->ver->sLabel,x->sLabel);
if(H[i+1]->ver->sLabel==x->sLabel) return i+1;
}
return 0;
}
//struct bnode *findHeap(struct ghead *x, struct bnode *T[]){
//int i;
//for(i=0;i<N;i++)
// if(T[i+1]->ver==x) return T[i+1];
//return NULL;
//}
decreaseKey(struct bnode *H[], struct ghead *V, float nkey){
struct bnode *k;
int i;
//k=findHeap(V,T);
//if(k!=NULL) i=k->index;
//else {printf("not found"); return;}
i=findIndex(V,H);
//printf("index=%d\n",i);
if(i!=0){
if(nkey > H[i]->ver->key){ printf("key error"); return;}
H[i]->ver=V;
H[i]->ver->key=nkey;
//T[i]->ver->sLabel=val->sLabel;
//T[i]->ver->pLabel=val->pLabel;
while(i>1 && H[Parent(i)]->ver->key > H[i]->ver->key){
//T[i]->index=Parent(i);
//T[Parent(i)]->index=i;
exchange(&H[i],&H[Parent(i)]);
//updateBH(T[i],T[Parent(i)]);
i=Parent(i);
}
}
return;
}
long computeCost(struct point a, struct point b){
return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
//generate random points IN 2D space
genplist(struct point list[],int j){
int i,x,y,fd;
srand((unsigned)time(NULL)+j+1000/(j+1));
for(i=0;i<N;i++){
x=rand()%XMAX;
y=rand()%YMAX;
list[i].x=x;
list[i].y=y;
}
}
// allocate memory for each header node
makeHead(struct ghead *V[]){
int i;
for(i=0;i<N;i++){
V[i]=(struct ghead *)malloc(sizeof(struct ghead));
V[i]->ptr=NULL;
V[i]->pLabel=-1;
V[i]->sLabel=i;
}
return;
}
//create memory for a node
struct gnode *getgnode(int j){
struct gnode *x=(struct gnode *)malloc(sizeof(struct gnode));
x->next=NULL;
x->label=j;
return x;
}
//connect used in copy tree
connectp(struct ghead *V[],int i, int j, int cost){
struct gnode *y,*x;
y=getgnode(j);
y->cost=cost;
//insert(V[i],j);
if (V[i]->ptr==NULL) V[i]->ptr=y;
else{
x=V[i]->ptr;
V[i]->ptr=y;
y->next=x;
}
}
//connects (i,j) in V
connect(struct ghead *V[],int i, int j, int cost){
struct gnode *y,*x;
//int cost=rand()%(N*N);
//if (cost==0) return;
y=getgnode(j);
y->cost=cost;
//insert(V[i],j);
if (V[i]->ptr==NULL) V[i]->ptr=y;
else{
x=V[i]->ptr;
V[i]->ptr=y;
y->next=x;
}
//insert(V[j],i);
y=getgnode(i);
y->cost=cost;
if (V[j]->ptr==NULL) V[j]->ptr=y;
else{
x=V[j]->ptr;
V[j]->ptr=y;
y->next=x;
}
return;
}
//generates complete graph
genpGraph(struct ghead *V[],struct point plist[]){
int i,j,count=0,k=0;
long cost;
//int a[10]={10,11,16,116,1,6,106,5,105,100};
makeHead(V);
//srand((unsigned)time(NULL));
for(i=0;i<N;i++){
for(j=i+1;j<N;j++){
cost=computeCost(plist[i],plist[j]);
//cost=(long)a[k++];
connect(V,i,j,cost);
count++;
}
}
//printf("edges=%d\n",count);
}
//generate MST using prims algorithm
mstPrimBin(struct ghead *V[], struct ghead *root){
int i;
struct bnode *H[N+1],*u;
struct gnode *v;
for(i=0;i<N;i++){
if (V[i]==root) V[i]->key=0;
else V[i]->key=inf;
H[i+1]=(struct bnode *) malloc (sizeof(struct bnode));
H[i+1]->ver=V[i];
//T[i+1]->index=i+1;
//addBT(T[i+1]);
}
H[0]=(struct bnode *) malloc (sizeof(struct bnode));
H[0]->index=N; //size is kept in T[0]
//buildMinHeap(T);
//printf("%d\t",T[0]->key);
while(H[0]->index!=0){ //Q not empty
u=extractMin(H);
//printf("min=%d:%d:%d\n",u->ver->key,u->ver->sLabel,u->index);
//printHeap(T);
//remBT(u);
for(v=u->ver->ptr;v!=NULL;v=v->next){
//printf("%d %d %d %d %d\n",u->ver->sLabel,v->label,v->cost,V[v->label]->key,findIndex(V[v->label],T));
if(findIndex(V[v->label],H) && v->cost < V[v->label]->key){
V[v->label]->pLabel=u->ver->sLabel;
//perform decreaseKey operation here.
//printf("\ndec(%d:%d)label=%d",V[v->label]->key,v->cost,V[v->label]->sLabel);
decreaseKey(H,V[v->label],v->cost);
//printHeap(T);
//V[v->label]->key=v->cost;
}
}
}
return;
}
//Obtain the adjacency list of Spanning tree
converToAdj(struct ghead *V[],struct ghead *T[]){
int i;
makeHead(T);
for(i=0;i<N;i++){
T[i]->pLabel=V[i]->pLabel;
T[i]->sLabel=V[i]->sLabel;
}
for(i=1;i<N;i++)
connect(T,i,V[i]->pLabel,V[i]->key);
}
//append an element to the path
addPath(struct list **p, int j){
struct list *a;
a=(struct list *) malloc(sizeof(struct list));
a->label=j;
a->next=*p;
*p=a;
}
//create arcs along the path
struct arc *makeArc(struct list *l){
int i,j;
struct arc *start,*p,*q;
struct list *t;
start=(struct arc*) malloc(sizeof(struct arc));
start->a=0;start->b=0;
//printf("%d",l->next->label);
start->next=NULL;
p=start;
for(t=l; t->next!=NULL; t=t->next){
i=t->label;j=t->next->label;
q=(struct arc*) malloc(sizeof(struct arc));
q->next=NULL;
q->a=i;
q->b=j;
p->next=q;
p=q;
}
//printf("inside makeArc\n");
//printArc(start->next);
return (start->next);
}
deleteList(struct list **a, int count){
int i;
struct list *temp;
for(i=0;i<count;i++){
temp=*a;
*a=(*a)->next;
free(temp);
}
}
//Convert the paths into arcs list
struct arc *concatArc(struct list *a, struct list *b){
int count=0;
struct arc *start,*p,*q;
struct list *l1=a,*l2=b;
while(l1!=NULL||l2!=NULL){
if (l1->label!=l2->label) break;
count++;
l1=l1->next;
l2=l2->next;
}
// delete count-1 element from list a and b;
deleteList(&a,count-1);
deleteList(&b,count-1);
//printf("inside concat\n");
//printPath(a);
//printPath(b);
p=makeArc(a);//printArc(p);
q=makeArc(b);//printArc(q);
start=p;
//concat
while(p->next!=NULL) p=p->next; //move to end of p;
p->next=q;
return start;
}
//obtain the path from i to j
struct arc *findPath(struct ghead *T[], int i, int j){
struct ghead *s,*t;
struct list *a=NULL,*b=NULL;
struct arc *p;
int k;
//printf("\nfindpath %d:%d\t",i,j);
s=T[i]; t=T[j];
while(s->pLabel!=-1){
addPath(&a,s->sLabel);
s=T[s->pLabel];
if (s==t) {addPath(&a,s->sLabel);
p=makeArc(a);return p;
}
}
if(s->pLabel==-1) {addPath(&a,0);}
//printPath(a);
s=T[i]; t=T[j];
while(t->pLabel!=-1){
addPath(&b,t->sLabel);
t=T[t->pLabel];
if (s==t) {
addPath(&b,s->sLabel);
p=makeArc(b);return p;
}
}
if(t->pLabel==-1) {addPath(&b,0);}
//printPath(b);
p=concatArc(a,b);
//printf("path(%d->%d)\n",i,j);
//printArc(p);
//printPath(a);
return p;
}
//return the cost of edge(i,j);
int getCost(struct ghead *V[], int i, int j){
struct gnode *v;
for(v=V[i]->ptr;v!=NULL;v=v->next)
if(v->label==j) return (v->cost);
return 0;
}
//remove arc p from T
removeEdge(struct ghead *T[],struct arc *p){
int i,j;
struct gnode *v,*q,*temp;
i=p->a;j=p->b;
v=T[i]->ptr;
q=v;//remove from insert at beginning
if(v->label==j){
T[i]->ptr=v->next;
free(v);goto l1;
}
while(v!=NULL){
if(v->label==j){
//v=v->next;
temp=v->next;
q->next=temp;
free(v);
v=temp;break;//return;
}
q=v;
v=v->next;
}
l1: v=T[j]->ptr;
q=v;//remove from beginning
if(v->label==i){
T[j]->ptr=v->next;
free(v);return;
}
while(v!=NULL){
if(v->label==i){
temp=v->next;
q->next=temp;
free(v);
v=temp;return;
}
q=v;
v=v->next;
}
}
//add an edge to T
addEdge(struct ghead *V[], struct ghead*T[], int i, int j){
struct gnode *y,*x;
int cost;
cost=getCost(V,i,j);
//printf("cost(%d:%d)is%d\t",i,j,cost);
connect(T,i,j,cost);
}
// copyTree(Dest,Source)
copyTree(struct ghead *s[],struct ghead *d[]){
int i;
struct gnode *v;
makeHead(d);
for(i=0;i<N;i++){
for(v=s[i]->ptr;v!=NULL;v=v->next)
connectp(d,i,v->label,v->cost);
}
return;
}
//check if min cost edge appears at tail or head
int isAtype(struct ghead *T[], struct arc *p, int s, int t, int *a, int *b){
struct arc *minArc;
int i=0;
long c,min;
if (p->next==NULL||p->next->next==NULL) return TRUE;
min=getCost(T,p->a,p->b);
minArc=p;
p=p->next;
while(p!=NULL){
c=getCost(T,p->a,p->b);
if(c<min){
min=c;
minArc=p;
//minArc->next=NULL;
}
p=p->next;
}
if (minArc->a==s || minArc->b==t || minArc->a==t ||minArc->b==s) return TRUE;
//if (isequal(minArc,s,t)) return TRUE;
//printf("%d,%d\n",s,t);
*a=minArc->a;*b=minArc->b;
//minArc->next=NULL;
//printArc(p);
return FALSE;
}
int findList(struct list *l, int k){
while(l!=NULL){
if(l->label==k) return TRUE;
l=l->next;
}
return FALSE;
}
int isequal(struct arc *p,int i,int j){
if((p->a==i&&p->b==j)||(p->a==j&&p->b==i))
return TRUE;
return FALSE;
}
struct arc *findNonEdgesv(struct ghead *T[]){
struct list *l=NULL,*k=NULL,*s,*t;
struct arc *start,*p,*q;
struct gnode *v;
int y,i;
//printf("valley path is\n");
//printArc(path);
addPath(&l,0);//initialise list with an arbitrary vertex
addPath(&k,0);
while(k!=NULL){
y=k->label;
deleteList(&k,1);//extract one element from Q
for(v=T[y]->ptr;v!=NULL;v=v->next){
if(findList(l,v->label)==0){
addPath(&l,v->label);
addPath(&k,v->label);
}
}
}
//list l has the vertices in one component
for(i=0;i<N;i++)
if(findList(l,i)==0) addPath(&k,i);
//now list k has other components vertices
//printf("components are");
//printPath(l);printPath(k);
//create arc of nonedge
start=(struct arc*) malloc(sizeof(struct arc));
start->a=0;start->b=0;
start->next=NULL;
p=start;
for(s=l;s!=NULL;s=s->next){
for(t=k;t!=NULL;t=t->next){
q=(struct arc*) malloc(sizeof(struct arc));
q->next=NULL;
q->a=s->label; q->b=t->label;
p->next=q;
p=q;
}
}
return (start->next);
}
updateParent(struct ghead *T[]){
struct list *q=NULL;
int i,u;
struct gnode *v;
//intialsize
for(i=1;i<N;i++){
T[i]->color=WHITE;
T[i]->key=inf;
T[i]->pLabel=-1;
}
T[0]->color=GRAY;
T[0]->key=0;
T[0]->pLabel=-1;
addPath(&q,0);
while(q!=NULL){
u=q->label;
deleteList(&q,1);
for(v=T[u]->ptr;v!=NULL;v=v->next){
if(T[v->label]->color==WHITE){
T[v->label]->color=GRAY;
T[v->label]->key=T[u]->key+1;
T[v->label]->pLabel=u;
addPath(&q,v->label);
}
}
T[u]->color=BLACK;
}
}
//Compute Energy for each vertex and hence total energy
long computeEnergy(struct ghead *T[],long *lb){
int i;
long max,gmax=0,mcost=0,m=0;
struct gnode *v;
for(i=0;i<N;i++){
//max=T[i]->ptr->cost;
max=0;
//mcost+=max;
for(v=T[i]->ptr;v!=NULL;v=v->next){
//mcost+=v->cost;
if(v->cost>max) max=v->cost;//find maximum of incident vertices
}
T[i]->pow=max; // store the energy for vertex T[i]
// printf("The power node %d= %ld\n",i,T[i]->pow);
m=m+T[i]->pow;
if(T[i]->pow >gmax) gmax=T[i]->pow;
}
*lb=gmax+mcost/2;
return m;
}
localMST(struct ghead *V[], struct ghead *T[],long mm,long *ml, int *inum, float *ani){
int i,j,a=0,b=0,minflag=0,iter=0;
int swapcount=0,succescnt,sccnt=0;
struct ghead *Tmin[N];
struct arc *kedge;
struct gnode *v;
long min,lb,mkv;
struct arc *q,*vpath,*path,*mstedge,*ne,*p,*pd,*vp,*vlist[(N-2)*(N-3)/2];
copyTree(T,Tmin);
min=mm;
do{ copyTree(Tmin,T); //copyTree(T,Td);
succescnt=0;//minflag=0;
//printAdj(Tmin);
for(i=0;i<N;i++){
for(v=T[i]->ptr;v!=NULL;v=v->next){
if(i < v->label){
q=(struct arc*) malloc(sizeof(struct arc));
q->a=i;
q->b=v->label;
q->next=NULL;
removeEdge(T,q);// disconnects the graph into 2 components P and Q
ne=findNonEdgesv(T); //find cut edges between P and Q
while(ne!=NULL){
if(!isequal(ne,q->a,q->b)){// nonedge other than removed edge
addEdge(V,T,ne->a,ne->b);// now T is a Spanning tree
//printf("%d:swap %d %d with %d %d\n",iter,i,v->label,ne->a,ne->b);
swapcount++;
updateParent(T);
*ml=computeEnergy(T,&lb);
if(*ml<min) {
succescnt++;sccnt++;
//printf("%d:swap %d %d with %d %d\n",iter,i,v->label,ne->a,ne->b);
min=*ml;copyTree(T,Tmin);
minflag=1;
}
removeEdge(T,ne);// again a disconnected graph
//printf("%d %d removed(disconnected)\n",ne->a,ne->b);
}
ne=ne->next;
}
//printf("trace i=%d j=%d",i,v->label);
addEdge(V,T,i,v->label);
}//end if(i<v->labe)
}
}
if(minflag){ *ml=min;// printf("Energy=%ld\n",min);
//printAdj(Tmin);
}
else *ml=mm;
iter++;
//printf("swap Count=%d\tsuccess Count=%d\titeration=%d\t Energy=%ld\n",swapcount,succescnt,iter,*ml);
} while(succescnt!=0);
//printf("swap Count=%d\tsuccess Count=%d\n",swapcount,sccnt);
*inum=computeInterfere(V,T,ani);
}
combinelocMST(struct ghead *V[],struct ghead *T[],long mm,int inum,float icnum, long *mcd, int *inumcd,long lb, float *ani){
struct ghead *Tmin[N];
float alpha,beta,r,max,ani1;
int swapcount=0,succescnt,sccnt=0;
int i,j,a=0,b=0,minflag=0,iter=0,inter,inumc;
long power,mc,lbound;
struct gnode *v;
struct arc *q,*ne,*p;
power=mm; inter=inum;
*ani=icnum;
copyTree(T,Tmin);
max=0;
do{ copyTree(Tmin,T); //copyTree(T,Td);
succescnt=0;//minflag=0;
//printAdj(Tmin);
for(i=0;i<N;i++){
for(v=T[i]->ptr;v!=NULL;v=v->next){
if(i < v->label){
q=(struct arc*) malloc(sizeof(struct arc));
q->a=i;
q->b=v->label;
q->next=NULL;
removeEdge(T,q);// disconnects the graph into 2 components P and Q
ne=findNonEdgesv(T); //find cut edges between P and Q
while(ne!=NULL){
if(!isequal(ne,q->a,q->b)){// nonedge other than removed edge
addEdge(V,T,ne->a,ne->b);// now T is a Spanning tree
//printf("%d:swap %d %d with %d %d\n",iter,i,v->label,ne->a,ne->b);
swapcount++;
updateParent(T);
mc=computeEnergy(T,&lbound);
inumc=computeInterfere(V,T,ani);
alpha=(float)(power-mc)/power;
beta= (float)(inter-inumc)/inter;
r=alpha+beta;
//if(r>0) printf("ratio=%f\n",r);
if(r > max){ //&& mc<2*lb)
//printf("iteration=%d ratio=%f\tEnergy=%ld\tInterference=%d\n",iter,r,mc,inumc);
succescnt++;sccnt++;
//printf("%d:swap %d %d with %d %d\n",iter,i,v->label,ne->a,ne->b);
max=r;copyTree(T,Tmin);
inter=inumc; power=mc;
minflag=1;
}
removeEdge(T,ne);// again a disconnected graph
//printf("%d %d removed(disconnected)\n",ne->a,ne->b);
}
ne=ne->next;
}
addEdge(V,T,i,v->label);
}//end if(i<v->labe)
}
}
if(minflag){ *mcd=power;*inumcd=inter;
//printAdj(Tmin);
}
else {*mcd=mm; *inumcd=inum;*ani=icnum;}
iter++;
//printf("swap Count=%d\tsuccess Count=%d\titeration=%d\t Energy=%ldInterfere=%d\n",swapcount,succescnt,iter,*mcd,*inumcd);
} while(succescnt!=0);
//printf("swap Count=%d\tsuccess Count=%d\n",swapcount,sccnt);
}
long min(long x, long y){
if (x<y) return(x);
else return y;
}
//returns cost of edge
long getCostp(struct ghead *V[], struct arc *e){
struct gnode *v;
for(v=V[e->a]->ptr;v!=NULL;v=v->next)
if(v->label==e->b) return (v->cost);
printf("cost error ");
}
insertEdge(struct arc **l, int u, int v){
struct arc *t;
t=(struct arc *) malloc(sizeof(struct arc));
t->a=u;
t->b=v;
t->ic=0;
t->next= *l;
*l=t;
}
struct arc *MSTpower(struct ghead *V[],struct ghead *T[],long *m, int *inum,long *lbound,float *ani){
struct ghead *root;
struct list *edgelist[N-1],*x;
struct arc *treeEdge=NULL;
struct gnode *v;
long min,lb;
int i;
root=V[0];
mstPrimBin(V,root);//call MST using PRIMS Algorithm
//printParent(V);
converToAdj(V,T);//obtain adj list for MST
//printf("The MST is\n");
//printAdj(T);//print the MST T.
*m=computeEnergy(T,&lb);
for(i=0;i<N-1;i++){
for(v=T[i]->ptr;v!=NULL;v=v->next)
if(i<v->label) insertEdge(&treeEdge,i,v->label);
// printf("(%d,%d)\t",i,v->label);
}
// Compute interference
*inum=computeInterfere(V,T,ani);
*lbound=lb;
return treeEdge;
}
int computeInterfere(struct ghead *V[], struct ghead *T[],float *ani){
int i,j,max=0;
float sum=0;
for(i=0;i<N;i++){
T[i]->inum=0;
}
for(i=0;i<N;i++){
for (j=0;j<N;j++)
if(j!=i)
{ //c=getCost(V,i,j)
if((T[j]->pow) >= getCost(V,i,j) )
{
(T[i]->inum)++;
}
}
}
for(i=0;i<N;i++){
if(T[i]->inum > max) max=T[i]->inum;
sum+=T[i]->inum;
//printf("\ninterfre of %d is = %d ",i,T[i]->inum);
}
*ani=sum/N;
return max;
}
main(){
long mm[CNT],ml[CNT],mc[CNT],lb;// energy variable
int inum[CNT],inuml[CNT],inumc[CNT]; // max interference
float ainum[CNT], ainuml[CNT],ainumc[CNT]; //average interference numbers
int i;
struct arc *mstedge;
struct ghead *V[N],*T[N];
struct point plist[N];
system("clear");
printf("No.of nodes =%d\n",N);
//execute CNT number of times
for(i=0;i<CNT;i++){
genplist(plist,i);
//printPlist(plist);
genpGraph(V,plist);
mstedge=MSTpower(V,T,&mm[i],&inum[i],&lb,&ainum[i]);//call MST heuristic
printf("MST Ener=%ld MSTInterference=%d\n",mm[i],inum[i]);
localMST(V,T,mm[i],&ml[i],&inuml[i],&ainuml[i]);
combinelocMST(V,T,mm[i],inum[i],ainum[i],&mc[i],&inumc[i],lb,&ainumc[i]);
printf("LocalPower=%ld LocalInter=%d\n",ml[i],inuml[i]);
printf("CombinePower=%ld combineInter=%d\n",mc[i],inumc[i]);
}
}