/** * Return some information about the CMP. * * @return A std::string that represents this object. **/ std::string toString() const { std::string s("CMP\n"); s += "- graph size: " + mtools::toString(graphSize()) + "\n"; s += "- number of clusters: " + mtools::toString(nbClusters()) + "\n"; s += " - number of trivial site: " + mtools::toString(nbTrivialClusters()) + "\n"; s += " - number of single clusters: " + mtools::toString(nbIsolatedClusters()) + "\n"; s += " - number of compounded clusters: " + mtools::toString(nbNonAtomicClusters()) + "\n"; s += "- maximum height: " + mtools::toString(maxHeight()) + "\n"; auto it = clusterActiveSet.rbegin(); s += "- Largest cluster:\n"; if (isMasterCluster()) { s += " - *** MASTER CLUSTER : contains ever other cluster in its action radius ***\n"; } s += " - size: " + mtools::toString((*it)->size) + "\n"; s += " - weight: " + mtools::toString((*it)->weight) + "\n"; s += " - height: " + mtools::toString((*it)->height) + "\n"; if (clusterActiveSet.size() > 1) { it++; s += "- 2nd largest cluster:\n"; s += " - size: " + mtools::toString((*it)->size) + "\n"; s += " - weight: " + mtools::toString((*it)->weight) + "\n"; s += " - height: " + mtools::toString((*it)->height) + "\n"; } if (clusterActiveSet.size() > 2) { it++; s += "- 3th largest cluster:\n"; s += " - size: " + mtools::toString((*it)->size) + "\n"; s += " - weight: " + mtools::toString((*it)->weight) + "\n"; s += " - height: " + mtools::toString((*it)->height) + "\n"; } return s; }
void BFS(headNode *listHead) { int size = graphSize(listHead) + 1; queue *q = init_queue(size); int *visited = (int*)malloc(sizeof(int)*size); int i = 0; for(i = 0; i < size; i++) visited[i] = 0; enqueue(q, listHead->key); visited[listHead->key] = 1; while(!isempty(q)) { int current = dequeue(q); printf("%d ", current); headNode *node = findNode(listHead, current); adjNode *adj = node->neighbor; while(adj != NULL) { if(!visited[adj->key]) { enqueue(q, adj->key); visited[adj->key] = 1; } adj = adj->next; } } }
void NFA::restoreToGraphSize(unsigned size) { ASSERT(size >= 1); ASSERT(size <= graphSize()); m_nodes.shrink(size); }
void DFS(headNode *listHead) { int size = graphSize(listHead) + 1; int *visited = (int*)malloc(sizeof(int)*(size)); int i = 0; for(i = 0; i < size; i++) visited[i] = 0; headNode *head = listHead; while(head!= NULL) { if(!visited[head->key]) DFS_visit(listHead, head, visited); head= head->next; } printf("\n"); }