00001
00002
00003
00004 PAIR (outcome)
00005 int *outcome;
00006
00007 { int u, w, temp;
00008
00009 #ifdef DEBUG
00010 printf("Pair v=%d\n",v);
00011 #endif
00012
00013 e = NEXTEDGE[v];
00014 while (SLACK(e) != 2*DELTA)
00015 e = NEXTPAIR[e];
00016 w = BEND (e);
00017 LINK[BMATE (w)] = -e;
00018 u = BMATE (v);
00019 while (LINK[u] != -e) {
00020 LINK[u] = -e;
00021 if (MATE[w] != DUMMYEDGE) {
00022 temp = v;
00023 v = w;
00024 w = temp; }
00025 v = BLINK (v);
00026 u = BMATE (v);
00027 }
00028 if (u == DUMMYVERTEX && v != w) {
00029 *outcome = 1;
00030 return;
00031 }
00032 newlast = v;
00033 newbase = v;
00034 oldfirst = NEXTVTX[v];
00035 LINK_PATH (e);
00036 LINK_PATH (OPPEDGE (e));
00037 NEXTVTX[newlast] = oldfirst;
00038 if (LASTVTX[newbase] == newbase)
00039 LASTVTX[newbase] = newlast;
00040 NEXTPAIR[DUMMYEDGE] = DUMMYEDGE;
00041 MERGE_PAIRS (newbase);
00042 i = NEXTVTX[newbase];
00043 do {
00044 MERGE_PAIRS (i);
00045 i = NEXTVTX[LASTVTX[i]];
00046 SCAN (i, 2*DELTA - SLACK(MATE[i]));
00047 i = NEXTVTX[LASTVTX[i]];
00048 } while (i != oldfirst);
00049 *outcome = 0;
00050 return;
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060 MERGE_PAIRS (v)
00061 int v;
00062
00063 {
00064 #ifdef DEBUG
00065 printf("Merge Pairs v=%d\n",v);
00066 #endif
00067
00068 NEXT_D[v] = LAST_D;
00069 pairpoint = DUMMYEDGE;
00070 f = NEXTEDGE[v];
00071 while (f != DUMMYEDGE) {
00072 e = f;
00073 neighbor = END[e];
00074 f = NEXTPAIR[f];
00075 if (BASE[neighbor] != newbase)
00076 INSERT_PAIR();
00077 }
00078 }
00079
00080
00081
00082
00083
00084
00085 LINK_PATH (e)
00086 int e;
00087
00088 { int u;
00089
00090 #ifdef DEBUG
00091 printf("Link Path e=%d-%d\n", END[OPPEDGE(e)], END[e]);
00092 #endif
00093
00094 v = BEND (e);
00095 while (v != newbase) {
00096 u = BMATE (v);
00097 LINK[u] = OPPEDGE (e);
00098 NEXTVTX[newlast] = v;
00099 NEXTVTX[LASTVTX[v]] = u;
00100 newlast = LASTVTX[u];
00101 i = v;
00102 BASE[i] = newbase;
00103 i = NEXTVTX[i];
00104 while (i != DUMMYVERTEX) {
00105 BASE[i] = newbase;
00106 i = NEXTVTX[i];
00107 }
00108 e = LINK[v];
00109 v = BEND (e);
00110 }
00111 }
00112
00113
00114
00115
00116
00117
00118
00119 INSERT_PAIR ()
00120
00121 { int del_e;
00122
00123 #ifdef DEBUG
00124 printf("Insert Pair e=%d-%d\n",END[OPPEDGE(e)],END[e]);
00125 #endif
00126
00127 del_e = SLACK(e)/2;
00128 nextpoint = NEXTPAIR[pairpoint];
00129
00130 while (END[nextpoint] < neighbor) {
00131 pairpoint = nextpoint;
00132 nextpoint = NEXTPAIR[nextpoint];
00133 }
00134 if (END[nextpoint] == neighbor) {
00135 if (del_e >= SLACK (nextpoint)/2)
00136 return;
00137 nextpoint = NEXTPAIR[nextpoint];
00138 }
00139 NEXTPAIR[pairpoint] = e;
00140 pairpoint = e;
00141 NEXTPAIR[e] = nextpoint;
00142 if (NEXT_D[newbase] > del_e)
00143 NEXT_D[newbase] = del_e;
00144 }
00145