1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
|
\par
\subsection{Prototypes and descriptions of {\tt Tree} methods}
\label{subsection:Tree:proto}
\par
This section contains brief descriptions including prototypes
of all methods that belong to the {\tt Tree} object.
\par
\subsubsection{Basic methods}
\label{subsubsection:Tree:proto:basics}
\par
As usual, there are four basic methods to support object creation,
setting default fields, clearing any allocated data, and free'ing
the object.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
Tree * Tree_new ( void ) ;
\end{verbatim}
\index{Tree_new@{\tt Tree\_new()}}
This method simply allocates storage for the {\tt Tree} structure
and then sets the default fields by a call to
{\tt Tree\_setDefaultFields()}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setDefaultFields ( Tree *tree ) ;
\end{verbatim}
\index{Tree_setDefaultFields@{\tt Tree\_setDefaultFields()}}
This method checks to see whether {\tt tree} is {\tt NULL}.
If so, an error message is printed and the program exits.
Otherwise, the structure's fields are set to default values:
{\tt n} is zero, {\tt root} is {\tt -1}, and {\tt par}, {\tt fch}
and {\tt sib} are all {\tt NULL}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_clearData ( Tree *tree ) ;
\end{verbatim}
\index{Tree_clearData@{\tt Tree\_clearData()}}
This method checks to see whether {\tt tree} is {\tt NULL}.
If so, an error message is printed and the program exits.
Otherwise, it releases any storage held by the parent, first child
and sibling vectors, then sets the structure's default fields
with a call to {\tt Tree\_setDefaultFields()}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_free ( Tree *tree ) ;
\end{verbatim}
\index{Tree_free@{\tt Tree\_free()}}
This method checks to see whether {\tt tree} is {\tt NULL}.
If so, an error message is printed and the program exits.
Otherwise, it releases any storage by a call to
{\tt Tree\_clearData()} then free's the storage for the
structure with a call to {\tt free()}.
%-----------------------------------------------------------------------
\end{enumerate}
\subsubsection{IO methods}
\label{subsubsection:Tree:proto:IO}
\par
There are the usual eight IO routines.
The file structure of a tree object is simple:
{\tt size},
{\tt root},
{\tt par[size]},
{\tt fch[size]} and
{\tt sib[size]}.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_readFromFile ( Tree *tree, char *fn ) ;
\end{verbatim}
\index{Tree_readFromFile@{\tt Tree\_readFromFile()}}
\par
If {\tt tree} or {\tt fn} are {\tt NULL},
or if {\tt fn} is not of the form
{\tt *.treef} (for a formatted file)
or {\tt *.treeb} (for a binary file),
an error message is printed and the method returns zero.
Otherwise, it tries to open the file and if it is successful,
it then calls {\tt Tree\_readFromFormattedFile()} or
{\tt Tree\_readFromBinaryFile()},
closes the file
and returns the value returned from the called routine.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_readFormattedFile ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_readFormattedFile@{\tt Tree\_readFormattedFile()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message is printed and
zero is returned.
Otherwise, the data is read in from the file.
If there are no errors in reading the data,
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fscanf}, zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_readBinaryFile ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_readBinaryFile@{\tt Tree\_readBinaryFile()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message
is printed and zero is returned.
Otherwise, the data is read in from the file.
If there are no errors in reading the data,
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fread}, zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_writeToFile ( Tree *tree, char *fn ) ;
\end{verbatim}
\index{Tree_writeToFile@{\tt Tree\_writeToFile()}}
\par
If {\tt tree} or {\tt fn} are {\tt NULL},
or if {\tt fn} is not of the form
{\tt *.treef} (for a formatted file)
or {\tt *.treeb} (for a binary file),
an error message is printed and the method returns zero.
Otherwise, it tries to open the file and if it is successful,
it then calls {\tt Tree\_writeFromFormattedFile()} or
{\tt Tree\_writeFromBinaryFile()},
closes the file
and returns the value returned from the called routine.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_writeFormattedFile ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_writeFormattedFile@{\tt Tree\_writeFormattedFile()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message is printed and
zero is returned.
Otherwise, the data is written to the file.
If there are no errors in writing the data,
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fprintf}, zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_writeBinaryFile ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_writeBinaryFile@{\tt Tree\_writeBinaryFile()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message
is printed and zero is returned.
Otherwise, the data is written to the file.
If there are no errors in writing the data,
the value {\tt 1} is returned.
If an IO error is encountered from {\tt fwrite}, zero is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_writeForHumanEye ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_writeForHumanEye@{\tt Tree\_writeForHumanEye()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message
is printed and zero is returned.
Otherwise, the method {\tt Tree\_writeStats()}
is called to write out the
header and statistics.
Then the parent, first child and sibling
values are printed out in three columns.
The value {\tt 1} is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_writeStats ( Tree *tree, FILE *fp ) ;
\end{verbatim}
\index{Tree_writeStats@{\tt Tree\_writeStats()}}
\par
If {\tt tree} or {\tt fp} are {\tt NULL} an error message
is printed and zero is returned.
Otherwise, the header and statistics are written.
The value {\tt 1} is returned.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsubsection{Initializer methods}
\label{subsubsection:Tree:proto:initializers}
\par
There are three initializers and two helper functions to set the
dimensions of the tree, allocate the three vectors, and fill the
information.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_init1 ( Tree *tree, int size ) ;
\end{verbatim}
\index{Tree_init1@{\tt Tree\_init1()}}
If {\tt tree} is {\tt NULL} or {\tt size} is negative,
an error message is printed and the program exits.
It then clears any previous data with a call to
{\tt Tree\_clearData()}, sets the size and allocates storage for
the three tree vectors using {\tt IVinit()}.
All entries in the three vectors are set to {\tt -1}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_init2 ( Tree *tree, int size, int par[] ) ;
\end{verbatim}
\index{Tree_init2@{\tt Tree\_init2()}}
If {\tt tree} is {\tt NULL} or {\tt size} is negative,
an error message is printed and the program exits.
Otherwise, the simple initializer {\tt Tree\_init1()} is called
and the entries in {\tt par[]} are copied into the parent vector.
The helper method {\tt Tree\_setFchSibRoot()} is then called to set
the other fields.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_init3 ( Tree *tree, int size, int par[], int fch[], int sib[] ) ;
\end{verbatim}
\index{Tree_init3@{\tt Tree\_init3()}}
If {\tt tree} is {\tt NULL} or {\tt size} is negative,
an error message is printed and the program exits.
Otherwise, the simple initializer {\tt Tree\_init1()} is called
and the entries in {\tt par[]}, {\tt fch[]} and {\tt sib[]}
are copied into their respective vectors.
The helper method {\tt Tree\_setRoot()} is then called to set
the root field.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setFchSibRoot ( Tree *tree ) ;
\end{verbatim}
\index{Tree_setFchSibRoot@{\tt Tree\_setFchSibRoot()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the root and the entries in the {\tt fch[]} and {\tt sib[]}
vectors are set using the entries in the {\tt par[]} vector.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setRoot ( Tree *tree ) ;
\end{verbatim}
\index{Tree_setRoot@{\tt Tree\_setRoot()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the vertices that are roots in the tree are linked by
their {\tt sib[]} field and the root of the tree is set to the head
of the list.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsubsection{Utility methods}
\label{subsubsection:Tree:proto:utilities}
\par
The utility methods return the number of bytes taken by the object,
aid in performing pre-order and post-order traversals, and return
statistics about the tree (e.g.,
the number of roots or leaves in the tree, or the number of
children of a node in the tree).
This functionality can be easily had by direct manipulation or
inquiry of the object, but these methods insulate the user from the
internals and allow us to change and improve the internals if
necessary.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_sizeOf ( Tree *tree ) ;
\end{verbatim}
\index{Tree_sizeOf@{\tt Tree\_sizeOf()}}
If {\tt tree} is {\tt NULL},
an error message is printed and the program exits.
Otherwise, the number of bytes taken by this object is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_postOTfirst ( Tree *tree ) ;
\end{verbatim}
\index{Tree_postOTfirst@{\tt Tree\_postOTfirst()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the first node in a post-order traversal is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_postOTnext ( Tree *tree, int v ) ;
\end{verbatim}
\index{Tree_postOTnext@{\tt Tree\_postOTnext()}}
If {\tt tree} is {\tt NULL}, {\tt tree->n < 1}
or {\tt v} is not in {\tt [0,tree->n-1]},
an error message is printed and the program exits.
Otherwise, the node that follows {\tt v}
in a post-order traversal is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_preOTfirst ( Tree *tree ) ;
\end{verbatim}
\index{Tree_preOTfirst@{\tt Tree\_preOTfirst()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the first node in a pre-order traversal is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_preOTnext ( Tree *tree, int v ) ;
\end{verbatim}
\index{Tree_preOTnext@{\tt Tree\_preOTnext()}}
If {\tt tree} is {\tt NULL}, {\tt tree->n < 1}
or {\tt v} is not in {\tt [0,tree->n-1]},
an error message is printed and the program exits.
Otherwise, the node that follows {\tt v}
in a pre-order traversal is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_nleaves ( Tree *tree ) ;
\end{verbatim}
\index{Tree_nleaves@{\tt Tree\_nleaves()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the number of leaves of the tree is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_nroots ( Tree *tree ) ;
\end{verbatim}
\index{Tree_nroots@{\tt Tree\_nroots()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the number of roots of the tree (really a forest)
is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_nchild ( Tree *tree, int v ) ;
\end{verbatim}
\index{Tree_nchild@{\tt Tree\_nchild()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the number of children of {\tt v} is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_maxNchild ( Tree *tree ) ;
\end{verbatim}
\index{Tree_maxNchild@{\tt Tree\_maxNchild()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the maximum number of children of any vertex is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_height ( Tree *tree ) ;
\end{verbatim}
\index{Tree_height@{\tt Tree\_height()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, the height of the tree is returned.
%-----------------------------------------------------------------------
\end{enumerate}
\subsubsection{Metrics methods}
\label{subsubsection:Tree:proto:metrics}
\par
Many operations need to know some {\it metric} defined on the nodes
in a tree.
Here are three examples:
the height of a node (the minimum distance from a descendant leaf),
the depth of a node (the distance from its root ancestor), or
the weight associated with a subtree rooted at a node.
Of course, a weight could be associated with each node, so the
height or depth becomes the weight of the nodes on the path.
\par
Metrics can be {\tt int}, {\tt float} or {\tt double}.
Because of the limitations of C, we need three separate methods for
each of the height, depth and subtree functions.
Each trio of methods differs only in the type of the vector
argument.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setSubtreeImetric ( Tree *tree, int vmetric[], int tmetric[] ) ;
void Tree_setSubtreeFmetric ( Tree *tree, float vmetric[], float tmetric[] ) ;
void Tree_setSubtreeDmetric ( Tree *tree, double vmetric[], double tmetric[] ) ;
\end{verbatim}
\index{Tree_setSubtreeImetric@{\tt Tree\_setSubtreeImetric()}}
\index{Tree_setSubtreeFmetric@{\tt Tree\_setSubtreeFmetric()}}
\index{Tree_setSubtreeDmetric@{\tt Tree\_setSubtreeDmetric()}}
If {\tt tree}, {\tt vmetric} or {\tt tmetric} are {\tt NULL}
or if {\tt tree->n < 1},
an error message is printed and the program exits.
The vector {\tt vmetric[]} contains weights for each node.
On return, {\tt tmetric[v]} contains the weight of the subtree
rooted at {\tt v}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setDepthImetric ( Tree *tree, int vmetric[], int dmetric[] ) ;
void Tree_setDepthFmetric ( Tree *tree, float vmetric[], float dmetric[] ) ;
void Tree_setDepthDmetric ( Tree *tree, double vmetric[], double dmetric[] ) ;
\end{verbatim}
\index{Tree_setDepthImetric@{\tt Tree\_setDepthImetric()}}
\index{Tree_setDepthFmetric@{\tt Tree\_setDepthFmetric()}}
\index{Tree_setDepthDmetric@{\tt Tree\_setDepthDmetric()}}
If {\tt tree}, {\tt vmetric} or {\tt dmetric} are {\tt NULL}
or if {\tt tree->n < 1},
an error message is printed and the program exits.
The vector {\tt vmetric[]} contains weights for each node.
On return, {\tt dmetric[v]} contains the depth of {\tt v} measured
as the weight of nodes on the path from {\tt v} to its root.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_setHeightImetric ( Tree *tree, int vmetric[], int hmetric[] ) ;
void Tree_setHeightFmetric ( Tree *tree, float vmetric[], float hmetric[] ) ;
void Tree_setHeightDmetric ( Tree *tree, double vmetric[], double hmetric[] ) ;
\end{verbatim}
\index{Tree_setHeightImetric@{\tt Tree\_setHeightImetric()}}
\index{Tree_setHeightFmetric@{\tt Tree\_setHeightFmetric()}}
\index{Tree_setHeightDmetric@{\tt Tree\_setHeightDmetric()}}
If {\tt tree}, {\tt vmetric} or {\tt hmetric} are {\tt NULL}
or if {\tt tree->n < 1},
an error message is printed and the program exits.
The vector {\tt vmetric[]} contains weights for each node.
On return, {\tt hmetric[v]} contains the height of {\tt v} measured
as the minimum path weight from {\tt v} to one of its descendant
leaves.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsubsection{Compression methods}
\label{subsubsection:Tree:proto:compression}
\par
Frequently a tree will need to be compressed in some manner.
Elimination trees usually have long chains of nodes at the higher
levels, where each chain of nodes corresponds to a supernode.
Liu's generalized row envelope methods partition the vertices by
longest chains \cite{liu91-generalizedEnvelope}.
In both cases, we can construct a map from each node to a set of
nodes to define a smaller, more compact tree.
Given such a map, we construct the smaller tree.
\par
A fundamental chain is a set of nodes $v_1, \ldots, v_m$ such that
(1) $v_1$ is a leaf or has two or more children,
(2) $v_{i+1}$ is the parent of $v_i$ for $1 \le i < m$,
and
(3) $v_m$ is either a root or has a sibling.
The set of fundamental chains is uniquely defined.
In the context of elimination trees, a fundamental chain is very
close to a fundamental supernode, and in many cases,
fundamental chains can be used to contruct the fronts with little
added fill and factor operations.
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
int Tree_fundChainMap ( Tree *tree, int map[] ) ;
\end{verbatim}
\index{Tree_fundChainMap@{\tt Tree\_fundChainMap()}}
If {\tt tree} is {\tt NULL}, {\tt tree->n < 1} or if {\tt map} is
{\tt NULL}, an error message is printed and the program exits.
On return, {\tt map[v]} contains the id of the fundamental chain
that contains {\tt v}.
If {\tt u} is a descendant of {\tt v}, then {\tt map[u] <=
map[v]}.
The number of fundamental chains is returned.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
Tree * Tree_compress ( Tree *tree, int map[] ) ;
\end{verbatim}
\index{Tree_compress@{\tt Tree\_compress()}}
If {\tt tree} is {\tt NULL}, {\tt tree->n < 1} or if {\tt map} is
{\tt NULL}, an error message is printed and the program exits.
The compressed tree is constructed and returned.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsubsection{Justification methods}
\label{subsubsection:Tree:proto:justify}
\par
Given a tree, how should the children of a node be ordered?
This ``justification'' can have a large impact in the working
storage for the front tree in the multifrontal algorithm.
Justification also is useful when displaying trees.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_leftJustify ( Tree *tree ) ;
\end{verbatim}
\index{Tree_leftJustify@{\tt Tree\_leftJustify()}}
If {\tt tree} is {\tt NULL} or {\tt tree->n < 1},
an error message is printed and the program exits.
Otherwise, if {\tt u} and {\tt v} are siblings, and {\tt u} comes
before {\tt v} in a post-order traversal, then the size of the
subtree rooted at {\tt u} is as large or larger than the size of
the subtree rooted at {\tt v}.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_leftJustifyI ( Tree *tree, int metric[] ) ;
void Tree_leftJustifyF ( Tree *tree, float metric[] ) ;
void Tree_leftJustifyD ( Tree *tree, double metric[] ) ;
\end{verbatim}
\index{Tree_leftJustifyI@{\tt Tree\_leftJustifyI()}}
\index{Tree_leftJustifyF@{\tt Tree\_leftJustifyF()}}
\index{Tree_leftJustifyD@{\tt Tree\_leftJustifyD()}}
If {\tt tree} is {\tt NULL}, {\tt tree->n < 1}
or {\tt metric} is {\tt NULL},
an error message is printed and the program exits.
Otherwise, if {\tt u} and {\tt v} are siblings, and {\tt u} comes
before {\tt v} in a post-order traversal, then the weight of the
subtree rooted at {\tt u} is as large or larger than the weight of
the subtree rooted at {\tt v}.
%-----------------------------------------------------------------------
\end{enumerate}
\par
\subsubsection{Permutation methods}
\label{subsubsection:Tree:proto:permutation}
\par
Often we need to extract a permutation from a tree, e.g., a
post-order traversal of an elimination tree gives an ordering for a
sparse matrix.
On other occasions, we need to permute a tree, i.e. re-label
the nodes.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
void Tree_fillNewToOldPerm ( Tree *tree, int newToOld[] ) ;
void Tree_fillOldToNewPerm ( Tree *tree, int oldToNew[] ) ;
void Tree_fillBothPerms ( Tree *tree, int newToOld[], int oldToNew[] ) ;
\end{verbatim}
\index{Tree_fillNewToOldPerm@{\tt Tree\_fillNewToOldPerm()}}
\index{Tree_fillOldToNewPerm@{\tt Tree\_fillOldToNewPerm()}}
\index{Tree_fillBothPerms@{\tt Tree\_fillBothPerms()}}
If {\tt tree} is {\tt NULL},
{\tt tree->n < 1} or a permutation vector is {\tt NULL},
an error message is printed and the program exits.
Otherwise, the permutation vector(s) is (are) filled with the
ordering of the nodes in a post-order traversal.
%-----------------------------------------------------------------------
\item
\begin{verbatim}
Tree * Tree_permute ( Tree *tree, int newToOld[], int oldToNew[] ) ;
\end{verbatim}
\index{Tree_permute@{\tt Tree\_permute()}}
If {\tt tree} is {\tt NULL},
{\tt tree->n < 1} or a permutation vector is {\tt NULL},
an error message is printed and the program exits.
Otherwise, a new tree is created with the same connectivity as the
old but the nodes are relabeled.
%-----------------------------------------------------------------------
\end{enumerate}
|