| 1 |
\input ctwimac |
| 2 |
\datethis |
| 3 |
\def\title{HAM} |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
\N{1}{1} |
| 9 |
Hamiltonian cycles. This program finds all Hamiltonian cycles of |
| 10 |
an undirected graph. [It's a slight revision of the program published |
| 11 |
in my paper ``Mini-indexes for literate programs,'' {\sl Software---Concepts |
| 12 |
and Tools\/ \bf15} (1994), 2--11.] The input graph should be in |
| 13 |
Stanford GraphBase format, and should be named on the command line |
| 14 |
as, for example, \.{foo.gb}. An optional second command-line parameter |
| 15 |
is a modulus~$m$, which causes every $m$th solution to be printed. |
| 16 |
|
| 17 |
We use a utility field to record the vertex degrees. |
| 18 |
|
| 19 |
\Y\B\4\D$\\{deg}$ \5 |
| 20 |
$\|u.{}$\|I\par |
| 21 |
\Y\B\8\#\&{include} \.{"gb\_graph.h"}\C{ the GraphBase data structures }\6 |
| 22 |
\8\#\&{include} \.{"gb\_save.h"}\C{ \PB{\\{restore\_graph}} }\7 |
| 23 |
\1\1\&{int} \\{main}(\&{int} \\{argc}${},\39{}$\&{char} ${}{*}\\{argv}[\,])\2% |
| 24 |
\2{}$\6 |
| 25 |
${}\{{}$\1\6 |
| 26 |
\&{Graph} ${}{*}\|g;{}$\6 |
| 27 |
\&{Vertex} ${}{*}\|x,\39{*}\|y,\39{*}\|z,\39{*}\\{tmax};{}$\6 |
| 28 |
\&{register} \&{Vertex} ${}{*}\|t,\39{*}\|u,\39{*}\|v;{}$\6 |
| 29 |
\&{register} \&{Arc} ${}{*}\|a,\39{*}\\{aa};{}$\6 |
| 30 |
\&{register} \&{int} \|d;\6 |
| 31 |
\&{Arc} ${}{*}\|b,\39{*}\\{bb};{}$\6 |
| 32 |
\&{int} \\{count}${}\K\T{0};{}$\6 |
| 33 |
\&{int} \\{dmin}${},\39\\{modulus};{}$\7 |
| 34 |
\X2:Process the command line, inputting the graph\X;\6 |
| 35 |
\X3:Prepare \PB{\|g} for backtracking, and find a vertex \PB{\|x} of minimum |
| 36 |
degree\X;\6 |
| 37 |
\&{for} ${}(\|v\K\|g\MG\\{vertices};{}$ ${}\|v<\|g\MG\\{vertices}+\|g\MG\|n;{}$ |
| 38 |
${}\|v\PP){}$\1\5 |
| 39 |
${}\\{printf}(\.{"\ \%ld"},\39\|v\MG\\{deg});{}$\2\6 |
| 40 |
\\{printf}(\.{"\\n"});\C{ TEMPORARY CHECK }\6 |
| 41 |
\&{if} ${}(\|x\MG\\{deg}<\T{2}){}$\5 |
| 42 |
${}\{{}$\1\6 |
| 43 |
${}\\{printf}(\.{"The\ minimum\ degree\ }\)\.{is\ \%ld\ (vertex\ \%s)!\\}\)% |
| 44 |
\.{n"},\39\|x\MG\\{deg},\39\|x\MG\\{name});{}$\6 |
| 45 |
\&{return} ${}{-}\T{1};{}$\6 |
| 46 |
\4${}\}{}$\2\6 |
| 47 |
\&{for} ${}(\|b\K\|x\MG\\{arcs};{}$ ${}\|b\MG\\{next};{}$ ${}\|b\K\|b\MG% |
| 48 |
\\{next}){}$\1\6 |
| 49 |
\&{for} ${}(\\{bb}\K\|b\MG\\{next};{}$ \\{bb}; ${}\\{bb}\K\\{bb}\MG\\{next}){}$% |
| 50 |
\5 |
| 51 |
${}\{{}$\1\6 |
| 52 |
${}\|v\K\|b\MG\\{tip};{}$\6 |
| 53 |
${}\|z\K\\{bb}\MG\\{tip};{}$\6 |
| 54 |
\X4:Find all simple paths of length \PB{$\|g\MG\|n-\T{2}$} from \PB{\|v} to % |
| 55 |
\PB{\|z}, avoiding \PB{\|x}\X;\6 |
| 56 |
\4${}\}{}$\2\2\6 |
| 57 |
${}\\{printf}(\.{"Altogether\ \%d\ solut}\)\.{ions.\\n"},\39\\{count});{}$\6 |
| 58 |
\&{for} ${}(\|v\K\|g\MG\\{vertices};{}$ ${}\|v<\|g\MG\\{vertices}+\|g\MG\|n;{}$ |
| 59 |
${}\|v\PP){}$\1\5 |
| 60 |
${}\\{printf}(\.{"\ \%ld"},\39\|v\MG\\{deg});{}$\2\6 |
| 61 |
\\{printf}(\.{"\\n"});\C{ TEMPORARY CHECK, SHOULD AGREE WITH FORMER VALUES }\6 |
| 62 |
\4${}\}{}$\2\par |
| 63 |
\mini |
| 64 |
\]{GB\_\,GRAPH}9 \|{u} \&{util} |
| 65 |
\]{GB\_\,GRAPH}10 \\{tip} \&{Vertex} ${}{*}{}$ |
| 66 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 67 |
\]{GB\_\,GRAPH}9 \\{arcs} \&{Arc} ${}{*}{}$ |
| 68 |
\]{GB\_\,GRAPH}9 \\{name} \&{char} ${}{*}{}$ |
| 69 |
\]"<stdio.h>" \\{printf} \zip |
| 70 |
\]{GB\_\,GRAPH}20 \|{n} \&{long} |
| 71 |
\]{GB\_\,GRAPH}20 \\{vertices} \&{Vertex} ${}{*}{}$ |
| 72 |
\]{GB\_\,GRAPH}10 \&{Arc} =\&{struct} |
| 73 |
\]{GB\_\,GRAPH}9 \&{Vertex} =\&{struct} |
| 74 |
\]{GB\_\,GRAPH}20 \&{Graph} =\&{struct} |
| 75 |
\]{GB\_\,SAVE}4 \\{restore\_graph} \&{Graph} ${}{*}(\,){}$ |
| 76 |
\]{GB\_\,GRAPH}8 \|{I} \&{long} |
| 77 |
}\FI |
| 78 |
|
| 79 |
\shortpage |
| 80 |
\M{2} |
| 81 |
\B\X2:Process the command line, inputting the graph\X${}\E{}$\6 |
| 82 |
\&{if} ${}(\\{argc}>\T{1}){}$\1\5 |
| 83 |
${}\|g\K\\{restore\_graph}(\\{argv}[\T{1}]){}$;\5 |
| 84 |
\2\&{else}\1\5 |
| 85 |
${}\|g\K\NULL;{}$\2\6 |
| 86 |
\&{if} ${}(\\{argc}<\T{3}\V\\{sscanf}(\\{argv}[\T{2}],\39\.{"\%d"},\39{\AND}% |
| 87 |
\\{modulus})\I\T{1}){}$\1\5 |
| 88 |
${}\\{modulus}\K\T{1000000000};{}$\2\6 |
| 89 |
\&{if} ${}(\R\|g\V\\{modulus}\Z\T{0}){}$\5 |
| 90 |
${}\{{}$\1\6 |
| 91 |
${}\\{fprintf}(\\{stderr},\39\.{"Usage:\ \%s\ foo.gb\ [m}\)\.{odulus]\\n"},\39% |
| 92 |
\\{argv}[\T{0}]);{}$\6 |
| 93 |
${}\\{exit}({-}\T{1});{}$\6 |
| 94 |
\4${}\}{}$\2\par |
| 95 |
\U1. |
| 96 |
\mini |
| 97 |
\]"<stdlib.h>" \\{exit} \zip |
| 98 |
\]"<stdio.h>" \\{stderr} \zip |
| 99 |
\]"<stdio.h>" \\{fprintf} \zip |
| 100 |
\[1 \\{modulus} \&{int} |
| 101 |
\]"<stdio.h>" \\{sscanf} \zip |
| 102 |
\[1 \\{argv} \&{char} ${}{*}[\,]{}$ |
| 103 |
\]{GB\_\,SAVE}4 \\{restore\_graph} \&{Graph} ${}{*}(\,){}$ |
| 104 |
\[1 \|{g} \&{Graph} ${}{*}{}$ |
| 105 |
\[1 \\{argc} \&{int} |
| 106 |
}\FI |
| 107 |
|
| 108 |
\M{3} |
| 109 |
Vertices that have already appeared in the path are ``taken,'' and |
| 110 |
their \PB{\\{taken}} field is nonzero. Initially we make all those fields zero. |
| 111 |
|
| 112 |
\Y\B\4\D$\\{taken}$ \5 |
| 113 |
$\|v.{}$\|I\par |
| 114 |
\Y\B\4\X3:Prepare \PB{\|g} for backtracking, and find a vertex \PB{\|x} of |
| 115 |
minimum degree\X${}\E{}$\6 |
| 116 |
$\\{dmin}\K\|g\MG\|n;{}$\6 |
| 117 |
\&{for} ${}(\|v\K\|g\MG\\{vertices};{}$ ${}\|v<\|g\MG\\{vertices}+\|g\MG\|n;{}$ |
| 118 |
${}\|v\PP){}$\5 |
| 119 |
${}\{{}$\1\6 |
| 120 |
${}\|v\MG\\{taken}\K\T{0};{}$\6 |
| 121 |
${}\|d\K\T{0};{}$\6 |
| 122 |
\&{for} ${}(\|a\K\|v\MG\\{arcs};{}$ \|a; ${}\|a\K\|a\MG\\{next}){}$\1\5 |
| 123 |
${}\|d\PP;{}$\2\6 |
| 124 |
${}\|v\MG\\{deg}\K\|d;{}$\6 |
| 125 |
\&{if} ${}(\|d<\\{dmin}){}$\1\5 |
| 126 |
${}\\{dmin}\K\|d,\39\|x\K\|v;{}$\2\6 |
| 127 |
\4${}\}{}$\2\par |
| 128 |
\U1. |
| 129 |
\mini |
| 130 |
\]{GB\_\,GRAPH}8 \|{I} \&{long} |
| 131 |
\]{GB\_\,GRAPH}9 \|{v} \&{util} |
| 132 |
\[1 \|{v} \&{register} \&{Vertex} ${}{*}{}$ |
| 133 |
\[1 \|{x} \&{Vertex} ${}{*}{}$ |
| 134 |
\[1 \\{deg} =\|u.\|I |
| 135 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 136 |
\]{GB\_\,GRAPH}9 \\{arcs} \&{Arc} ${}{*}{}$ |
| 137 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 138 |
\[1 \|{d} \&{register} \&{int} |
| 139 |
\]{GB\_\,GRAPH}20 \\{vertices} \&{Vertex} ${}{*}{}$ |
| 140 |
\]{GB\_\,GRAPH}20 \|{n} \&{long} |
| 141 |
\[1 \|{g} \&{Graph} ${}{*}{}$ |
| 142 |
\[1 \\{dmin} \&{int} |
| 143 |
}\FI |
| 144 |
|
| 145 |
\N{1}{4} |
| 146 |
The data structures. I use one simple rule to cut off unproductive |
| 147 |
branches of the search tree: If one of the vertices we could move to next |
| 148 |
is adjacent to only one other unused vertex, we must move to it now. |
| 149 |
|
| 150 |
The moves will be recorded in the vertex array of \PB{\|g}. More precisely, the |
| 151 |
\PB{\|k}th vertex of the path will be \PB{$\|t\MG\\{vert}$} when \PB{\|t} is |
| 152 |
the \PB{\|k}th vertex of |
| 153 |
the graph. If the move was not forced, \PB{$\|t\MG\\{ark}$} will point to the |
| 154 |
Arc |
| 155 |
record representing the edge from \PB{$\|t\MG\\{vert}$} to \PB{$(\|t+\T{1})\MG% |
| 156 |
\\{vert}$}; otherwise |
| 157 |
\PB{$\|t\MG\\{ark}$} will be \PB{$\NULL$}. |
| 158 |
|
| 159 |
This program is a typical backtrack program. I am more comfortable doing |
| 160 |
it with labels and goto statements than with while loops, but some day |
| 161 |
I may learn my lesson. |
| 162 |
|
| 163 |
\Y\B\4\D$\\{vert}$ \5 |
| 164 |
$\|w.{}$\|V\par |
| 165 |
\B\4\D$\\{ark}$ \5 |
| 166 |
$\|x.{}$\|A\par |
| 167 |
\Y\B\4\X4:Find all simple paths of length \PB{$\|g\MG\|n-\T{2}$} from \PB{\|v} |
| 168 |
to \PB{\|z}, avoiding \PB{\|x}\X${}\E{}$\6 |
| 169 |
$\|t\K\|g\MG\\{vertices}{}$;\5 |
| 170 |
${}\\{tmax}\K\|t+\|g\MG\|n-\T{1};{}$\6 |
| 171 |
${}\|x\MG\\{taken}\K\T{1}{}$;\5 |
| 172 |
${}\|t\MG\\{vert}\K\|x{}$;\5 |
| 173 |
${}\|t\MG\\{ark}\K\NULL;{}$\6 |
| 174 |
\4\\{advance}:\5 |
| 175 |
\X5:Increase \PB{\|t} and update the data structures to show that vertex \PB{% |
| 176 |
\|v} is now taken; \PB{\&{goto} \\{backtrack}} if no further moves are possible% |
| 177 |
\X;\6 |
| 178 |
\4\\{try\_next}:\5 |
| 179 |
\X7:Look at edge \PB{\|a} and its successors, advancing if it is a valid move% |
| 180 |
\X;\6 |
| 181 |
\4\\{restore}:\5 |
| 182 |
\X6:Downdate the data structures to the state they were in when level \PB{\|t} |
| 183 |
was entered\X;\6 |
| 184 |
\4\\{backtrack}:\5 |
| 185 |
\X8:Decrease \PB{\|t}, if possible, and try the next possibility; or \PB{% |
| 186 |
\&{goto} \\{done}}\X;\6 |
| 187 |
\\{done}:\par |
| 188 |
\U1. |
| 189 |
\mini |
| 190 |
\[1 \|{x} \&{register} \&{Vertex} ${}{*}{}$ |
| 191 |
\]{GB\_\,GRAPH}9 \|{x} \&{util} |
| 192 |
\]{GB\_\,GRAPH}9 \|{w} \&{util} |
| 193 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 194 |
\[1 \|{z} \&{Vertex} ${}{*}{}$ |
| 195 |
\[1 \|{v} \&{register} \&{Vertex} ${}{*}{}$ |
| 196 |
\[3 \\{taken} =\|v.\|I |
| 197 |
\]{GB\_\,GRAPH}20 \|{n} \&{long} |
| 198 |
\[1 \\{tmax} \&{Vertex} ${}{*}{}$ |
| 199 |
\]{GB\_\,GRAPH}20 \\{vertices} \&{Vertex} ${}{*}{}$ |
| 200 |
\]{GB\_\,GRAPH}8 \|{A} \&{Arc} ${}{*}{}$ |
| 201 |
\]{GB\_\,GRAPH}8 \|{V} \&{Vertex} ${}{*}{}$ |
| 202 |
\[1 \|{t} \&{register} \&{Vertex} ${}{*}{}$ |
| 203 |
\[1 \|{g} \&{Graph} ${}{*}{}$ |
| 204 |
}\FI |
| 205 |
|
| 206 |
\M{5} |
| 207 |
\B\X5:Increase \PB{\|t} and update the data structures to show that vertex \PB{% |
| 208 |
\|v} is now taken; \PB{\&{goto} \\{backtrack}} if no further moves are possible% |
| 209 |
\X${}\E{}$\6 |
| 210 |
$\|t\PP;{}$\6 |
| 211 |
${}\|t\MG\\{vert}\K\|v;{}$\6 |
| 212 |
${}\|v\MG\\{taken}\K\T{1};{}$\6 |
| 213 |
\&{if} ${}(\|v\E\|z){}$\5 |
| 214 |
${}\{{}$\1\6 |
| 215 |
\&{if} ${}(\|t\E\\{tmax}){}$\1\5 |
| 216 |
\X9:Record a solution\X;\2\6 |
| 217 |
\&{goto} \\{backtrack};\6 |
| 218 |
\4${}\}{}$\2\6 |
| 219 |
\&{for} ${}(\\{aa}\K\|v\MG\\{arcs},\39\|y\K\NULL;{}$ \\{aa}; ${}\\{aa}\K\\{aa}% |
| 220 |
\MG\\{next}){}$\5 |
| 221 |
${}\{{}$\1\6 |
| 222 |
${}\|u\K\\{aa}\MG\\{tip};{}$\6 |
| 223 |
${}\|d\K\|u\MG\\{deg}-\T{1};{}$\6 |
| 224 |
\&{if} ${}(\|d\E\T{1}\W\|u\MG\\{taken}\E\T{0}){}$\5 |
| 225 |
${}\{{}$\1\6 |
| 226 |
\&{if} (\|y)\1\5 |
| 227 |
\&{goto} \\{restore};\C{ restoration will stop at \PB{\\{aa}} }\2\6 |
| 228 |
${}\|y\K\|u;{}$\6 |
| 229 |
\4${}\}{}$\2\6 |
| 230 |
${}\|u\MG\\{deg}\K\|d;{}$\6 |
| 231 |
\4${}\}{}$\2\6 |
| 232 |
\&{if} (\|y)\5 |
| 233 |
${}\{{}$\1\6 |
| 234 |
${}\|t\MG\\{ark}\K\NULL;{}$\6 |
| 235 |
${}\|v\K\|y;{}$\6 |
| 236 |
\&{goto} \\{advance};\6 |
| 237 |
\4${}\}{}$\2\6 |
| 238 |
${}\|a\K\|v\MG\\{arcs}{}$;\par |
| 239 |
\U4. |
| 240 |
\mini |
| 241 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 242 |
\[4 \\{advance} label |
| 243 |
\[4 \\{ark} =\|x.\|A |
| 244 |
\[4 \\{restore} label |
| 245 |
\[1 \\{deg} =\|u.\|I |
| 246 |
\[1 \|{d} \&{register} \&{int} |
| 247 |
\]{GB\_\,GRAPH}10 \\{tip} \&{Vertex} ${}{*}{}$ |
| 248 |
\[1 \|{u} \&{register} \&{Vertex} ${}{*}{}$ |
| 249 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 250 |
\[1 \|{y} \&{Vertex} ${}{*}{}$ |
| 251 |
\]{GB\_\,GRAPH}9 \\{arcs} \&{Arc} ${}{*}{}$ |
| 252 |
\[1 \\{aa} \&{register} \&{Arc} ${}{*}{}$ |
| 253 |
\[4 \\{backtrack} label |
| 254 |
\[1 \\{tmax} \&{Vertex} ${}{*}{}$ |
| 255 |
\[1 \|{z} \&{Vertex} ${}{*}{}$ |
| 256 |
\[3 \\{taken} =\|v.\|I |
| 257 |
\[1 \|{v} \&{register} \&{Vertex} ${}{*}{}$ |
| 258 |
\[4 \\{vert} =\|w.\|V |
| 259 |
\[1 \|{t} \&{register} \&{Vertex} ${}{*}{}$ |
| 260 |
}\FI |
| 261 |
|
| 262 |
\M{6} |
| 263 |
\B\X6:Downdate the data structures to the state they were in when level \PB{% |
| 264 |
\|t} was entered\X${}\E{}$\6 |
| 265 |
\&{for} ${}(\|a\K\|t\MG\\{vert}\MG\\{arcs};{}$ ${}\|a\I\\{aa};{}$ ${}\|a\K\|a% |
| 266 |
\MG\\{next}){}$\1\5 |
| 267 |
${}\|a\MG\\{tip}\MG\\{deg}\PP{}$;\2\par |
| 268 |
\U4. |
| 269 |
\mini |
| 270 |
\[1 \\{deg} =\|u.\|I |
| 271 |
\]{GB\_\,GRAPH}10 \\{tip} \&{Vertex} ${}{*}{}$ |
| 272 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 273 |
\[1 \\{aa} \&{register} \&{Arc} ${}{*}{}$ |
| 274 |
\]{GB\_\,GRAPH}9 \\{arcs} \&{Arc} ${}{*}{}$ |
| 275 |
\[4 \\{vert} =\|w.\|V |
| 276 |
\[1 \|{t} \&{register} \&{Vertex} ${}{*}{}$ |
| 277 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 278 |
}\FI |
| 279 |
|
| 280 |
\M{7} |
| 281 |
\B\X7:Look at edge \PB{\|a} and its successors, advancing if it is a valid move% |
| 282 |
\X${}\E{}$\6 |
| 283 |
\&{while} (\|a)\5 |
| 284 |
${}\{{}$\1\6 |
| 285 |
${}\|v\K\|a\MG\\{tip};{}$\6 |
| 286 |
\&{if} ${}(\|v\MG\\{taken}\E\T{0}){}$\5 |
| 287 |
${}\{{}$\1\6 |
| 288 |
${}\|t\MG\\{ark}\K\|a;{}$\6 |
| 289 |
\&{goto} \\{advance};\6 |
| 290 |
\4${}\}{}$\2\6 |
| 291 |
${}\|a\K\|a\MG\\{next};{}$\6 |
| 292 |
\4${}\}{}$\2\6 |
| 293 |
\4\\{restore\_all}:\5 |
| 294 |
${}\\{aa}\K\NULL{}$;\C{ all moves tried; we fall through to \PB{\\{restore}} }% |
| 295 |
\par |
| 296 |
\U4. |
| 297 |
\mini |
| 298 |
\[4 \\{restore} label |
| 299 |
\[1 \\{aa} \&{register} \&{Arc} ${}{*}{}$ |
| 300 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 301 |
\[4 \\{advance} label |
| 302 |
\[4 \\{ark} =\|x.\|A |
| 303 |
\[1 \|{t} \&{register} \&{Vertex} ${}{*}{}$ |
| 304 |
\[3 \\{taken} =\|v.\|I |
| 305 |
\]{GB\_\,GRAPH}10 \\{tip} \&{Vertex} ${}{*}{}$ |
| 306 |
\[1 \|{v} \&{register} \&{Vertex} ${}{*}{}$ |
| 307 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 308 |
}\FI |
| 309 |
|
| 310 |
\M{8} |
| 311 |
\B\X8:Decrease \PB{\|t}, if possible, and try the next possibility; or \PB{% |
| 312 |
\&{goto} \\{done}}\X${}\E{}$\6 |
| 313 |
$\|t\MG\\{vert}\MG\\{taken}\K\T{0};{}$\6 |
| 314 |
${}\|t\MM;{}$\6 |
| 315 |
\&{if} ${}(\|t\MG\\{ark}){}$\5 |
| 316 |
${}\{{}$\1\6 |
| 317 |
${}\|a\K\|t\MG\\{ark}\MG\\{next};{}$\6 |
| 318 |
\&{goto} \\{try\_next};\6 |
| 319 |
\4${}\}{}$\2\6 |
| 320 |
\&{if} ${}(\|t\E\|g\MG\\{vertices}){}$\1\5 |
| 321 |
\&{goto} \\{done};\2\6 |
| 322 |
\&{goto} \\{restore\_all};\C{ the move was forced }\par |
| 323 |
\U4. |
| 324 |
\mini |
| 325 |
\[7 \\{restore\_all} label |
| 326 |
\[4 \\{done} label |
| 327 |
\]{GB\_\,GRAPH}20 \\{vertices} \&{Vertex} ${}{*}{}$ |
| 328 |
\[1 \|{g} \&{Graph} ${}{*}{}$ |
| 329 |
\[4 \\{try\_next} label |
| 330 |
\]{GB\_\,GRAPH}10 \\{next} \&{Arc} ${}{*}{}$ |
| 331 |
\[1 \|{a} \&{register} \&{Arc} ${}{*}{}$ |
| 332 |
\[4 \\{ark} =\|x.\|A |
| 333 |
\[3 \\{taken} =\|v.\|I |
| 334 |
\[4 \\{vert} =\|w.\|V |
| 335 |
\[1 \|{t} \&{register} \&{Vertex} ${}{*}{}$ |
| 336 |
}\FI |
| 337 |
|
| 338 |
\M{9} |
| 339 |
\B\X9:Record a solution\X${}\E{}$\6 |
| 340 |
${}\{{}$\1\6 |
| 341 |
${}\\{count}\PP;{}$\6 |
| 342 |
\&{if} ${}(\\{count}\MOD\\{modulus}\E\T{0}){}$\5 |
| 343 |
${}\{{}$\1\6 |
| 344 |
${}\\{printf}(\.{"\%d:\ "},\39\\{count});{}$\6 |
| 345 |
\&{for} ${}(\|u\K\|g\MG\\{vertices};{}$ ${}\|u\Z\\{tmax};{}$ ${}\|u\PP){}$\1\5 |
| 346 |
${}\\{printf}(\.{"\%s\ "},\39\|u\MG\\{vert}\MG\\{name});{}$\2\6 |
| 347 |
\\{printf}(\.{"\\n"});\6 |
| 348 |
\4${}\}{}$\2\6 |
| 349 |
\4${}\}{}$\2\par |
| 350 |
\U5. |
| 351 |
\mini |
| 352 |
\]{GB\_\,GRAPH}9 \\{name} \&{char} ${}{*}{}$ |
| 353 |
\[4 \\{vert} =\|w.\|V |
| 354 |
\[1 \\{tmax} \&{Vertex} ${}{*}{}$ |
| 355 |
\]{GB\_\,GRAPH}20 \\{vertices} \&{Vertex} ${}{*}{}$ |
| 356 |
\[1 \|{g} \&{Graph} ${}{*}{}$ |
| 357 |
\[1 \|{u} \&{register} \&{Vertex} ${}{*}{}$ |
| 358 |
\]"<stdio.h>" \\{printf} \zip |
| 359 |
\[1 \\{modulus} \&{int} |
| 360 |
\[1 \\{count} \&{int} |
| 361 |
}\FI |
| 362 |
|
| 363 |
\inx |
| 364 |
\fin |
| 365 |
\con |