/* MAXABC: return the maximum of three integers */ /* 1. FLOWGRAPH: R1 enter artificial 1 . . . . . . . | . +-------+-------+ . a | F T | b . v v . R2 . 3 2 . . c | | d . +-----> 4 <-----+ . | R3 . h + ------+ . | T | f . |F v . e | . | R4 5 . v . | g . 6 <-----+ . exit . . . . . . 2. CYCLOMETRIC COMPLEXITY: Predicates (2) + 1 = Edges (8) - Nodes (6) + 1 = Regions (4) - 1 = 3 3. BASIS SET OF CYCLES: 1. 1-2-4-5-6-1 2. 1-3-4-6-1 3. 1-2-4-6-1 Note: The following is NOT a basis cycle because it is not independent: 4. 1-3-4-5-6-1 Proof: Consider eight edges: a,b,c,d,e,f,g,h a b c d e f g h In Cycle 1: : (0 1 0 1 0 1 1 1) In Cycle 2: : +(1 0 1 0 1 0 0 1) In Cycle 3: : -(0 1 0 1 1 0 0 1) ----------------- In Cycle 4: : =(1 0 1 0 0 1 1 1) 4. LINEARLY INDEPENDENT PATHS 5. FEASABLE (YES/NO) 6. TEST CASES 7. RESULT (a,b,c) (max) 1. 1-2-4-5-6 YES 2,1,3 3 2. 1-3-4-6 YES 1,3,2 3 3. 1-2-4-6 YES 3,2,1 3 See maxabc.bat */ #include int debug = 0; /* instrumentation for the line #'s*/ int L(int i) { if (debug) printf("%d-",i); return 1; } int maxabc(int a, int b, int c) { int max; if (L(1)&&(a>b)) { L(2); max = a; } else { L(3); max = b; } if (L(4)&&(c>max)) { L(5); max=c; } L(6); if (debug) printf("\nActual : max=%d\n",max); return max; } int main(int argc, char *argv[]) { int a, b, c; if (argc > 1) { debug = 1; printf("Path : "); } scanf("%d %d %d",&a,&b,&c); printf("Maximum:%d\n",maxabc(a,b,c)); }