void CGameGraphBuilder::generate_edges (const float &start, const float &amount) { Progress (start); Msg ("Generating edges"); graph_type::const_vertex_iterator I = graph().vertices().begin(); graph_type::const_vertex_iterator E = graph().vertices().end(); for ( ; I != E; ++I) { fill_neighbours ((*I).second->vertex_id()); generate_edges ((*I).second->vertex_id()); } Msg ("%d edges built",graph().edge_count()); Progress (start + amount); }
// computes the current 13 3-node circuits of s1-t1+neighbours // and s2-t2+neighbours. Puts results in sub-a 13*1 vector. // computes the future 13 3-node circuits of s1-t2 and neighbours // and s2-t1+neighbours. Puts results in add-a 13*1 vector. // Takes into account that double edges are switched void fill_13_dbl(Network *N,int s1,int t1,int s2,int t2,int sub[14],int add[14]) { int sarr1[ARR_NUM]; int tarr1[ARR_NUM]; int sarr2[ARR_NUM]; int tarr2[ARR_NUM]; int sarr1_len,tarr1_len,sarr2_len,tarr2_len; register int i; int state_var; int index; int old_triple[ARR_NUM][4]; int new_triple[ARR_NUM][4]; int old_len=0; int new_len=0; int first,second,third; zero_neighbours(sarr1,&sarr1_len); zero_neighbours(tarr1,&tarr1_len); zero_neighbours(sarr2,&sarr2_len); zero_neighbours(tarr2,&tarr2_len); fill_neighbours(N,s1,t1,1,sarr1,&sarr1_len); fill_neighbours(N,t1,s1,0,tarr1,&tarr1_len); fill_neighbours(N,s2,t2,1,sarr2,&sarr2_len); fill_neighbours(N,t2,s2,0,tarr2,&tarr2_len); for (i=0;i<14;i++) { sub[i]=0; add[i]=0; } for (i=0;i<ARR_NUM;i++) { old_triple[i][0]=0;old_triple[i][1]=0;old_triple[i][2]=0;old_triple[i][3]=0; new_triple[i][0]=0;new_triple[i][1]=0;new_triple[i][2]=0;new_triple[i][3]=0; } old_len=0; new_len=0; // fprintf(GNRL_ST.mat_metrop_fp,"starting old set\n"); /* update sub with the circuits of sarr1,s1,t1 */ for (i=0;i<sarr1_len;i++) { refine(old_triple,&old_len,sarr1[i],s1,t1); } /* update sub with the circuits of s1,t1,tarr1 */ for (i=0;i<tarr1_len;i++) { refine(old_triple,&old_len,s1,t1,tarr1[i]); } /* update sub with the circuits of sarr2,s2,t2 */ for (i=0;i<sarr2_len;i++) { refine(old_triple,&old_len,sarr2[i],s2,t2); } /* update sub with the circuits of s2,t2,tarr2 */ for (i=0;i<tarr2_len;i++) { refine(old_triple,&old_len,s2,t2,tarr2[i]); } /********* New bug fix - when a node connects to both s1 and t2 **********/ /* update sub with the circuits of sarr1,s1,t2 */ for (i=0;i<sarr1_len;i++) { refine(old_triple,&old_len,sarr1[i],s1,t2); } /* update sub with the circuits of s1,t2,tarr2 */ for (i=0;i<tarr2_len;i++) { refine(old_triple,&old_len,s1,t2,tarr2[i]); } /* update sub with the circuits of sarr2,s2,t1 */ for (i=0;i<sarr2_len;i++) { refine(old_triple,&old_len,sarr2[i],s2,t1); } /* update sub with the circuits of s2,t1,tarr1 */ for (i=0;i<tarr1_len;i++) { refine(old_triple,&old_len,s2,t1,tarr1[i]); } for (i=0;i<old_len;i++) { first=old_triple[i][1]; second=old_triple[i][2]; third=old_triple[i][3]; state_var=32*is_edge(N,first,second)+16*is_edge(N,second,third)+8*is_edge(N,third,first) +4*is_edge(N,second,first)+2*is_edge(N,third,second)+is_edge(N,first,third); index=elm(state_var); if ((index>0)&&(index<=13)) sub[index]=sub[index]+1; state_var=32*is_edge2_dbl(N,first,second,s1,t1,s2,t2)+16*is_edge2_dbl(N,second,third,s1,t1,s2,t2)+8*is_edge2(N,third,first,s1,t1,s2,t2) +4*is_edge2_dbl(N,second,first,s1,t1,s2,t2)+2*is_edge2_dbl(N,third,second,s1,t1,s2,t2)+is_edge2_dbl(N,first,third,s1,t1,s2,t2); index=elm(state_var); if ((index>0)&&(index<=13)) add[index]=add[index]+1; } }