1 /*  instance.c  */
2 
3 #include "../Tree.h"
4 
5 /*--------------------------------------------------------------------*/
6 /*
7    -------------------------------------------------
8    purpose -- return the number of nodes in the tree
9 
10    created -- 98jun12, cca
11    -------------------------------------------------
12 */
13 int
Tree_nnodes(Tree * tree)14 Tree_nnodes (
15    Tree   *tree
16 ) {
17 /*
18    ---------------
19    check the input
20    ---------------
21 */
22 if ( tree == NULL ) {
23    fprintf(stderr, "\n fatal error in Tree_nnodes(%p)"
24            "\n bad input\n", tree) ;
25    exit(-1) ;
26 }
27 return(tree->n) ; }
28 
29 /*--------------------------------------------------------------------*/
30 /*
31    --------------------------------------
32    purpose -- return the root of the tree
33 
34    created -- 98jun12, cca
35    --------------------------------------
36 */
37 int
Tree_root(Tree * tree)38 Tree_root (
39    Tree   *tree
40 ) {
41 /*
42    ---------------
43    check the input
44    ---------------
45 */
46 if ( tree == NULL ) {
47    fprintf(stderr, "\n fatal error in Tree_root(%p)"
48            "\n bad input\n", tree) ;
49    exit(-1) ;
50 }
51 return(tree->root) ; }
52 
53 /*--------------------------------------------------------------------*/
54 /*
55    ------------------------------------------------
56    purpose -- return a pointer to the parent vector
57 
58    created -- 98jun12, cca
59    ------------------------------------------------
60 */
61 int *
Tree_par(Tree * tree)62 Tree_par (
63    Tree   *tree
64 ) {
65 /*
66    ---------------
67    check the input
68    ---------------
69 */
70 if ( tree == NULL ) {
71    fprintf(stderr, "\n fatal error in Tree_par(%p)"
72            "\n bad input\n", tree) ;
73    exit(-1) ;
74 }
75 return(tree->par) ; }
76 
77 /*--------------------------------------------------------------------*/
78 /*
79    -----------------------------------------------------
80    purpose -- return a pointer to the first child vector
81 
82    created -- 98jun12, cca
83    -----------------------------------------------------
84 */
85 int *
Tree_fch(Tree * tree)86 Tree_fch (
87    Tree   *tree
88 ) {
89 /*
90    ---------------
91    check the input
92    ---------------
93 */
94 if ( tree == NULL ) {
95    fprintf(stderr, "\n fatal error in Tree_fch(%p)"
96            "\n bad input\n", tree) ;
97    exit(-1) ;
98 }
99 return(tree->fch) ; }
100 
101 /*--------------------------------------------------------------------*/
102 /*
103    -------------------------------------------------
104    purpose -- return a pointer to the sibling vector
105 
106    created -- 98jun12, cca
107    -------------------------------------------------
108 */
109 int *
Tree_sib(Tree * tree)110 Tree_sib (
111    Tree   *tree
112 ) {
113 /*
114    ---------------
115    check the input
116    ---------------
117 */
118 if ( tree == NULL ) {
119    fprintf(stderr, "\n fatal error in Tree_sib(%p)"
120            "\n bad input\n", tree) ;
121    exit(-1) ;
122 }
123 return(tree->sib) ; }
124 
125 /*--------------------------------------------------------------------*/
126