void FastPlanarSubgraph::computeDelEdges(const Graph &G, const EdgeArray<int> *pCost, const EdgeArray<edge> *backTableEdges, List<edge> &delEdges) { if (m_nRuns <= 0) { // Compute st-numbering NodeArray<int> numbering(G,0); int n = stNumber(G,numbering); OGDF_ASSERT_IF(dlConsistencyChecks,testSTnumber(G,numbering,n)) planarize(G,numbering,delEdges); } else { int bestSolution = INT_MAX; for(int i = 1; i <= m_nRuns && bestSolution > 1; ++i) { List<edge> currentDelEdges; // Compute (randomized) st-numbering NodeArray<int> numbering(G,0); int n = stNumber(G,numbering,0,0,true); OGDF_ASSERT_IF(dlConsistencyChecks,testSTnumber(G,numbering,n)) planarize(G,numbering,currentDelEdges); if(pCost == 0) { int currentSolution = currentDelEdges.size(); if(currentSolution < bestSolution) { bestSolution = currentSolution; delEdges.clear(); delEdges.conc(currentDelEdges); } } else { int currentSolution = 0; ListConstIterator<edge> it; for(it = currentDelEdges.begin(); it.valid(); ++it) if(backTableEdges != 0) currentSolution += (*pCost)[(*backTableEdges)[*it]]; else currentSolution += (*pCost)[*it]; if(currentSolution < bestSolution) { bestSolution = currentSolution; delEdges.clear(); delEdges.conc(currentDelEdges); } } } } }
main(int argc, char *argv[]) { FILE *fptr; if(argc != 2) { printf("\nWrong arguments!\n"); printf("Usage: ./indicateLine <filename>"); printf("\nPlease redo.\n\n"); } else { printf("\n\tIndicate Line Program\n"); printf("Input file: %s\n\n", argv[1]); if ((fptr = fopen(argv[1], "r")) == NULL) printf("Cannot open %s.\n\n", argv[1]); else { numbering(fptr); fclose(fptr); } } return 0; }
int main(void) { char operator; bignum_t operand[4]; memset(operand, 0, sizeof(bignum_t)*4); sprintf(operand[3].dig, "%d", 2147483247), numbering(&operand[3]); while (scanf("%s %c %s", operand[0].dig, &operator, operand[1].dig)==3) { numbering(&operand[0]), numbering(&operand[1]); printf("%s %c %s\n", operand[0].dig, operator, operand[1].dig); if (cmp(&operand[0], &operand[3])>0) printf("first number too big\n"); if (cmp(&operand[1], &operand[3])>0) printf("second number too big\n"); if ('+'==operator) plus(&operand[0], &operand[1], &operand[2]); else if ('*'==operator) mult(&operand[0], &operand[1], &operand[2]); if (cmp(&operand[2], &operand[3])>0) printf("result too big\n"); } return 0; }
int label(char p[64][64]) { int y, x, num = 2; for (y=0; y<64; y++) { for (x=0; x<64; x++) { if (p[y][x]==1) { numbering(p, y, x, num); num++; if (num > 255) return 1; } } } return 0; }
void numbering(char p[64][64], int y, int x, int num) { int v, u; p[y][x] = num; if (x!=0 && p[y][x-1]==1) numbering(p, y, x-1, num); if (x!=63 && p[y][x+1]==1) numbering(p, y, x+1, num); if (y!=0) { if (x!=0 && p[y-1][x-1]==1) numbering(p, y-1, x-1, num); if (x!=63 && p[y-1][x+1]==1) numbering(p, y-1, x+1, num); if (p[y-1][x]==1) numbering(p, y-1, x, num); } if (y!=63) { if (x!=0 && p[y+1][x-1]==1) numbering(p, y+1, x-1, num); if (x!=63 && p[y+1][x+1]==1) numbering(p, y+1, x+1, num); if (p[y+1][x]==1) numbering(p, y+1, x, num); } }
// // Prepare planarity test for one cluster // bool CconnectClusterPlanar::preparation( Graph &G, cluster &cl, node superSink) { int bcIdSuperSink = -1; // ID of biconnected component that contains superSink // Initialization with -1 necessary for assertion bool cPlanar = true; NodeArray<node> tableNodes(G, nullptr); EdgeArray<edge> tableEdges(G, nullptr); NodeArray<bool> mark(G, 0); EdgeArray<int> componentID(G); // Determine Biconnected Components int bcCount = biconnectedComponents(G, componentID); // Determine edges per biconnected component Array<SList<edge> > blockEdges(0, bcCount - 1); for (edge e : G.edges) { blockEdges[componentID[e]].pushFront(e); } // Determine nodes per biconnected component. Array<SList<node> > blockNodes(0, bcCount - 1); for (int i = 0; i < bcCount; i++) { for (edge e : blockEdges[i]) { if (!mark[e->source()]) { blockNodes[i].pushBack(e->source()); mark[e->source()] = true; } if (!mark[e->target()]) { blockNodes[i].pushBack(e->target()); mark[e->target()] = true; } } if (superSink && mark[superSink]) { OGDF_ASSERT(bcIdSuperSink == -1); bcIdSuperSink = i; } for (node v : blockNodes[i]) { if (mark[v]) mark[v] = false; else { OGDF_ASSERT(mark[v]); // v has been placed two times on the list. } } } // Perform planarity test for every biconnected component if (bcCount == 1) { // Compute st-numbering NodeArray<int> numbering(G,0); #ifdef OGDF_DEBUG int n = #endif (superSink) ? stNumber(G,numbering,nullptr,superSink) : stNumber(G,numbering); OGDF_ASSERT_IF(dlConsistencyChecks,testSTnumber(G,numbering,n)) EdgeArray<edge> backTableEdges(G,nullptr); for(edge e : G.edges) backTableEdges[e] = e; cPlanar = doTest(G,numbering,cl,superSink,backTableEdges); } else { for (int i = 0; i < bcCount; i++) { #ifdef OGDF_DEBUG if(int(ogdf::debugLevel)>=int(dlHeavyChecks)){ cout<<endl<<endl<<"-----------------------------------"; cout<<endl<<endl<<"Component "<<i<<endl;} #endif Graph C; for (node v : blockNodes[i]) { node w = C.newNode(); tableNodes[v] = w; #ifdef OGDF_DEBUG if (int(ogdf::debugLevel) >= int(dlHeavyChecks)){ cout << "Original: " << v << " New: " << w << endl; } #endif } NodeArray<node> backTableNodes(C,nullptr); for (edge e : blockEdges[i]) { edge f = C.newEdge(tableNodes[e->source()],tableNodes[e->target()]); tableEdges[e] = f; } EdgeArray<edge> backTableEdges(C,nullptr); for (edge e : blockEdges[i]) backTableEdges[tableEdges[e]] = e; // Compute st-numbering NodeArray<int> numbering(C,0); if (bcIdSuperSink == i) { #ifdef OGDF_DEBUG int n = #endif stNumber(C,numbering,nullptr,tableNodes[superSink]); OGDF_ASSERT_IF(dlConsistencyChecks,testSTnumber(C,numbering,n)) cPlanar = doTest(C,numbering,cl,tableNodes[superSink],backTableEdges); } else { #ifdef OGDF_DEBUG int n = #endif stNumber(C,numbering); OGDF_ASSERT_IF(dlConsistencyChecks,testSTnumber(C,numbering,n)) cPlanar = doTest(C,numbering,cl,nullptr,backTableEdges); } if (!cPlanar) break; } } return cPlanar; }