//is only called when CC not connected => m_eTreeArray is initialized void PlanRepInc::deleteTreeConnection(int i, int j) { edge e = m_eTreeArray(i, j); if (e == nullptr) return; edge nexte = nullptr; OGDF_ASSERT(e); OGDF_ASSERT(m_treeEdge[e]); //we have to take care of treeConnection edges that //are already crossed while ((e->target()->degree() == 4) && m_treeEdge[e->adjTarget()->cyclicSucc()->cyclicSucc()->theEdge()]) { nexte = e->adjTarget()->cyclicSucc()->cyclicSucc()->theEdge(); OGDF_ASSERT(original(nexte) == 0) delEdge(e); e = nexte; } delEdge(e); m_eTreeArray(i, j) = nullptr; m_eTreeArray(j, i) = nullptr; OGDF_ASSERT(isConnected(*this)); }//deleteTreeConnection
/* *删除环中ve1->ve2的一条边,构造一个新环 *@param[in] ve1 顶点1 *@param[in] ve2 顶点2 *@param[in] loop 当前环 *@return 新生成的环 */ Loop* EulerOperator::kemr(Vertex *ve1, Vertex *ve2, Loop *loop) { Half_Edge *he1,*he2; Half_Edge *head = loop->he; while(head->ve1!=ve1 || head->ve2!=ve2) head = head->next; he1 = head; he2 = he1->getAdjacent(); he2->prev->next = he1->next; he1->next->prev = he2->prev; he1->prev->next = he2->next; he2->next->prev = he1->prev; //创建新环 Loop* loop2 = new Loop; loop2->he = he2->prev; he2->prev->loop = loop2; insertLoop(loop->face,loop2); loop->he = he1->prev; he1->prev->loop = loop; delEdge(loop->face->solid,he1->edge); return loop2; }
/* Assuming the file exists and is an acyclic graph, print the vertices in a topological order * Use the algorithm that finds no-predecessor vertices and deletes their successor edges. * ALERT: modifies the graph by deleting edges. * * Solves topocycleExercise.c */ void toposort2(GraphInfo gi) { Graph g = gi->graph; int numV = numVerts(g); short done[numV]; // 1 if vertex already printed, otherwise 0 for (int i = 0; i < numV; i++) done[i] = 0; for (int numPrinted = 0; numPrinted < numV; numPrinted++) { /* set noPred to a vertex with no predecessors and not already done */ int noPred; int* ps; // predecessor list for (int v = 0; v < numV; v++) { if (!done[v]) { ps = predecessors(g, v); if (ps[0] == -1 ) { // list is empty? noPred = v; break; } } } /* print noPred and mark as done */ printf("%s ", gi->vertnames[noPred]); done[noPred] = 1; /* get successors of noPred and delete them */ int* snoPred = successors(gi->graph, noPred); for (int i = 0; snoPred[i] != -1; i++) delEdge(gi->graph, noPred, snoPred[i]); } /* cleanup */ printf("\n"); }
void MainWindow::work() { QString fileName=pathE->text(); for(int i=0;i<fileName.length();i++) if(fileName[i]=='\\') fileName[i]='/'; int picNum=numE->text().toInt(); wd=new ImageWidget(NULL,fileName,picNum); matchFBtn->setVisible(wd->tp.linev.size()==Hei); findMBtn->setVisible(true); findSBtn->setVisible(true); preBtn->setVisible(true); addBtn->setVisible(true); delBtn->setVisible(true); redoBtn->setVisible(true); nextBtn->setVisible(true); zinBtn->setVisible(true); zoutBtn->setVisible(true); // listSBtn->setVisible(true); connect(listSBtn,SIGNAL(clicked()),this,SLOT(listSameLine())); connect(findMBtn,SIGNAL(clicked()),this,SLOT(findMatch())); connect(findSBtn,SIGNAL(clicked()),this,SLOT(findSameLine())); connect(preBtn,SIGNAL(clicked()),this,SLOT(getPre())); connect(nextBtn,SIGNAL(clicked()),this,SLOT(getNext())); connect(addBtn,SIGNAL(clicked()),this,SLOT(addEdge())); connect(delBtn,SIGNAL(clicked()),this,SLOT(delEdge())); connect(redoBtn,SIGNAL(clicked()),this,SLOT(redo())); connect(dispBtn,SIGNAL(clicked()),this,SLOT(disp())); connect(matchFBtn,SIGNAL(clicked()),this,SLOT(matchFinall())); connect(zinBtn,SIGNAL(clicked()),this,SLOT(zoomin())); connect(zoutBtn,SIGNAL(clicked()),this,SLOT(zoomout())); updateLayout(); wd->show(); }
void ParallelCoordinatesGraphProxy::deleteData(const unsigned int dataId) { if (getDataLocation() == NODE) { delNode(node(dataId)); } else { delEdge(edge(dataId)); } }
SRDAGGraph::~SRDAGGraph() { while(edges_.getN()){ delEdge(edges_[0]); } while(vertices_.getN()){ delVertex(vertices_[0]); } }
// embeds constraint graph such that all sources and sinks lie in a common // face void CompactionConstraintGraphBase::embed() { NodeArray<bool> onExternal(*this,false); const CombinatorialEmbedding &E = *m_pOR; face fExternal = E.externalFace(); for(adjEntry adj : fExternal->entries) onExternal[m_pathNode[adj->theNode()]] = true; // compute lists of sources and sinks SList<node> sources, sinks; for(node v : nodes) { if (onExternal[v]) { if (v->indeg() == 0) sources.pushBack(v); if (v->outdeg() == 0) sinks.pushBack(v); } } // determine super source and super sink node s,t; if (sources.size() > 1) { s = newNode(); for (node v : sources) newEdge(s,v); } else s = sources.front(); if (sinks.size() > 1) { t = newNode(); for (node v : sinks) newEdge(v,t); } else t = sinks.front(); edge st = newEdge(s,t); bool isPlanar = planarEmbed(*this); if (!isPlanar) OGDF_THROW(AlgorithmFailureException); delEdge(st); if (sources.size() > 1) delNode(s); if (sinks.size() > 1) delNode(t); }
bool Graph::flipConn(int i, int j) { if (not areConnected(i,j)) addEdge(i,j); else { delEdge(i,j); if (not isConnected()) { addEdge(i,j); return false; } } return true; }
PiSDFGraph::~PiSDFGraph() { while(edges_.getN() > 0) delEdge(edges_[0]); while(bodies_.getN() > 0){ if(bodies_[0]->isHierarchical()){ bodies_[0]->getSubGraph()->~PiSDFGraph(); StackMonitor::free(PISDF_STACK, bodies_[0]->getSubGraph()); } delVertex(bodies_[0]); } while(configs_.getN() > 0) delVertex(configs_[0]); while(inputIfs_.getN() > 0) delVertex(inputIfs_[0]); while(outputIfs_.getN() > 0) delVertex(outputIfs_[0]); while(params_.getN() > 0) delParam(params_[0]); }
graph *updateGraph(graph *G,int sig) { //switch to the updation type switch(sig) { case 1: { //ADDING NUMBER OF EDGES// //variable declaration int i,j,edgeCount;//i.e number of edges //take number of edges printf("Enter the number of edges to be added: "); scanf("%d",&edgeCount); //take arrays to store edge end names char *from[edgeCount],*to[edgeCount]; //TAKING EDGES STARTS HERE printf("\n\tEnter the names of ends of edges:\n"); fflush(stdin); for(i=0;i<edgeCount;i++) { printf("\n\t\tEnd names for %dth Edge:\n",i+1); from[i]=(char *)malloc(sizeof(char)); to[i]=(char *)malloc(sizeof(char)); printf("\t\t\tEdge from end: "); from[i]=takeString(); printf("\t\t\tEdge to end: "); to[i]=takeString(); } //TAKING EDGES ENDS HERE //Add these edges to graph G=addEdge(G,from,to,edgeCount); //show message showMessage(4); break; } case 2: { //ADDING NUMBER OF VERTICES// //Variable declaration int i,noOfVert;//i.e number of vertices //Take number of vertices printf("Enter the number of vertices to be added: "); scanf("%d",&noOfVert); //take array to store the names char *vertName[noOfVert]; //TAKING VERTICES STARTS HERE printf("Enter the names of vertices:\n"); fflush(stdin); for(i=0;i<noOfVert;i++) { printf("Name of Vertex-%d: ",i+1); vertName[i]=(char *)malloc(sizeof(char)); vertName[i]=takeString(); } //TAKING VERTICES ENDS HERE //Add them to the Graph G=addVertex(G,vertName,noOfVert); //show message showMessage(5); break; } case 3: { //DELETING NUMBER OF EDGES// //variable declaration int i,j,edgeCount;//i.e number of edges //take number of edges printf("Enter the number of edges to be deleted: "); scanf("%d",&edgeCount); //take arrays to store edge end names char *from[edgeCount],*to[edgeCount]; //TAKING EDGES STARTS HERE printf("\n\tEnter the names of ends of edges:\n"); fflush(stdin); for(i=0;i<edgeCount;i++) { printf("\n\t\tEnd names for %dth Edge:\n",i+1); from[i]=(char *)malloc(sizeof(char)); to[i]=(char *)malloc(sizeof(char)); printf("\t\t\tEdge from end: "); from[i]=takeString(); printf("\t\t\tEdge to end: "); to[i]=takeString(); } //TAKING EDGES ENDS HERE //Delete the edges from the graph G=delEdge(G,from,to,edgeCount); //show message showMessage(6); break; } case 4: { //DELETING NUMBER OF VERTICES// //Variable declaration int i,noOfVert;//i.e number of vertices //Take number of vertices printf("Enter the number of vertices to be deleted: "); scanf("%d",&noOfVert); //take array to store the names char *vertName[noOfVert]; //TAKING VERTICES STARTS HERE printf("Enter the names of vertices:\n"); fflush(stdin); for(i=0;i<noOfVert;i++) { printf("Name of Vertex-%d: ",i+1); vertName[i]=(char *)malloc(sizeof(char)); vertName[i]=takeString(); } //TAKING VERTICES ENDS HERE //Delete them from the Graph G=delVertex(G,vertName,noOfVert); //show message showMessage(7); break; } default: { showMessage(3); break; } } return G; }
GLMmodel* L0ByEdge::doL0(double parpha, double pbeta, double plambda, int pmaxtimes) { int cc = 1, i, j, k; double tsum[3], sum; //得到边,求info getEdge(); if(pmaxtimes >= 0){ arpha = parpha; beta = pbeta; lambda = plambda; maxtimes = pmaxtimes; }else{ autoGetParameter(); } initInfo(); delEdge(); p = new double*[3]; v = new double*[3]; if(NULL == p || NULL == v){ printf("Error in L0ByEdge::doL0----- p , v\n"); return NULL; } for(i = 0;i < 3;i++){ p[i] = new double[(int)meshmodel->numvertices + infocnt]; v[i] = new double[(int)meshmodel->numvertices]; if(NULL == p[i] || NULL == v[i]){ printf("Error in L0ByEdge::doL0----- p[%d] , v[%d]\n",i,i); return NULL; } } for(i = 0; i < 3;i++){ for(j = 0;j < (int)meshmodel->numvertices;j++){ p[i][j] = model[3 * j + i]; v[i][j] = model[3 * j + i]; } } for(i = (int)meshmodel->numvertices;i < (int)meshmodel->numvertices + arinfocnt;i++){ for(j = 0;j < 3;j++){ p[j][i] = 0; } } //得到排序后二环领域,包括自身点 initVerSpreadNeighborVer(); //稀疏求解初始化 SubSolving s_l0(verSpreadNeighborVer, info, infocnt, arinfocnt, (int)meshmodel->numvertices); s_l0.init(); while(cc <= maxtimes){ updateInfo(); for(i = arinfocnt;i < infocnt;i++){ sum = 0; for(j = 0;j < 3;j++) tsum[j] = 0; for(j = 0;j < 4;j++) { for(k = 0;k < 3;k++){ tsum[k] += info[i][j].w * model[info[i][j].data * 3 + k]; } } for(j = 0;j < 3;j++){ sum += tsum[j] * tsum[j]; } if(sum <= lambda / beta){ for(j = 0;j < 3;j++) p[j][i + (int)meshmodel->numvertices] = 0.0; } else{ for(j = 0;j < 3;j++) p[j][i + (int)meshmodel->numvertices] = beta * tsum[j]; } } //传入beta,arpha s_l0.getParameter(p[0], v[0], info, beta, arpha); s_l0.update(); for(i = 0;i < 3;i++){ //传入p,v s_l0.getParameter(p[i], v[i], info, beta, arpha); s_l0.slove(); for(j = 0;j < (int)meshmodel->numvertices;j++){ model[3 * j + i] = v[i][j]; } } printf("%d\t time finished\n",cc); cc++; beta = beta * sqrt(2); arpha = arpha / 2; } //删除info,和关系链表 delInfo(); delVerSpreadNeighborVer(); for(i = 0;i < (int)meshmodel->numvertices;i++){ for(j = 0;j < 3;j++){ meshmodel->vertices[3 * (i + 1) + j] = model[3 * i + j]; } } return meshmodel; }
void Graph::flipEdge(int i, int j) { areConnected(i,j) ? delEdge(i,j):addEdge(i,j); }
void Graph::setEdge(int i, int j, int value){ if (value) addEdge(i,j); else delEdge(i,j); }