set<GraphNode*> Algorithms::clique(set< GraphNode* > data,GraphNode * parent,int traversed){ if(traversed>=(int)parent->friend_list.size()-1){ return data; } GraphNode* curNode=parent->friend_list[traversed+1]; set<GraphNode*> data1=clique(data,parent,traversed+1); set<GraphNode*> data2; bool flag=1; set<GraphNode*>::iterator it=data.end(); for(it=data.begin() ; it!=data.end(); it++ ){ flag=0; for(vector<GraphNode*>::iterator it1=(*it)->friend_list.begin() ; it1!=(*it)->friend_list.end(); it1++ ){ if(caseInsensitiveStringCompare((*it1)->name,curNode->name)){ flag=1; break; } } if(flag==0)break; } if(it==data.end() ){ data.insert(parent->friend_list[traversed+1]); data2=clique(data,parent,traversed+1); } return data1.size()>data2.size()?data1:data2; }
GraphNode* Algorithms::findByID(string s){ int size=G.size(); for(int i=0;i<G.size();i++){ if(caseInsensitiveStringCompare(G[i]->entry_code,s))return G[i]; } return NULL; }
static int locateOneElement(char *buf) { char *ptr; char **rc; char **i; if (PHYSFS_exists(buf)) return 1; /* quick rejection: exists in current case. */ ptr = strrchr(buf, '/'); /* find entry at end of path. */ if (ptr == NULL) { rc = PHYSFS_enumerateFiles("/"); ptr = buf; } /* if */ else { *ptr = '\0'; rc = PHYSFS_enumerateFiles(buf); *ptr = '/'; ptr++; /* point past dirsep to entry itself. */ } /* else */ for (i = rc; *i != NULL; i++) { if (caseInsensitiveStringCompare(*i, ptr) == 0) { strcpy(ptr, *i); /* found a match. Overwrite with this case. */ PHYSFS_freeList(rc); return 1; } /* if */ } /* for */ /* no match at all... */ PHYSFS_freeList(rc); return 0; } /* locateOneElement */