SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
orderTree.h
Go to the documentation of this file.
1 /* This program is free software: you can redistribute it and/or modify
2  * it under the terms of the GNU General Public License as published by
3  * the Free Software Foundation, either version 3 of the License, or
4  * (at your option) any later version.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program. If not, see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright (C) 2009 - 2012 Jun Liu and Jieping Ye
15  */
16 
17 
18 #ifndef ORDERTREE_SLEP
19 #define ORDERTREE_SLEP
20 
21 #define IGNORE_IN_CLASSLIST
22 
23 #include <shogun/lib/config.h>
24 #ifdef USE_GPL_SHOGUN
25 
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <time.h>
29 #include <math.h>
30 
31 
32 /*
33  * In this file, we propose an O(n^2) algorithm for solving the problem:
34  *
35  * min 1/2 \|x - u\|^2
36  * s.t. x_i \ge x_j \ge 0, (i,j) \in I,
37  *
38  * where I is the edge set of the tree
39  *
40  *
41  */
42 
43 /*
44  * Last updated on January, 21, 2011
45  *
46  * 1) the function merge is a non-recursive process for merging one tree with the other
47  *
48  * 2) we follow the writeup to revise the function computeMaximalMean
49  *
50  */
51 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53 IGNORE_IN_CLASSLIST struct NodeNum
54 {
55  int node_num;
56  struct NodeNum *next;
57 };
58 
59 IGNORE_IN_CLASSLIST struct ChildrenNum
60 {
61  int children_num;
62  int *children;
63 };
64 
65 IGNORE_IN_CLASSLIST struct Node
66 {
67  int flag; /*if the maximal root-tree of the subtree rooted at this node has been computed, flag=1, otherwise 0*/
68  double m; /*During the computation, it stores the maximal mean from this node to (grandson) child node
69  *The number of nodes on this path is stored in num
70  *
71  *It is intialized with the value of u(node_num)
72  */
73  int num; /*the number of nodes, whose avarage gives the maximal mean---x*/
74  struct Node *brother; /*the pointer to the brother node(s)*/
75  struct Node *child; /*the pointer to the child node(s)*/
76  struct NodeNum *firstNode; /*the first node in the "maximal mean" group*/
77  struct NodeNum *lastNode; /*the last node in the "maximal mean" group*/
78 };
79 #endif
80 
81 /*
82  * We build a tree with the input from a file
83  *
84  * The file has n rows represented in the following format
85  *
86  | parent | number of children | children
87  18 3 10 13 17
88  10 3 5 8 9
89  13 2 11 12
90  17 3 13 14 15
91  5 2 1 4
92  8 2 6 7
93  9 0
94  11 0
95  12 0
96  14 0
97  15 0
98  16 0
99  1 0
100  4 2 2 3
101  6 0
102  7 0
103  2 0
104  3 0
105  *
106  *
107  * Each row provides the information of one parent node and its children
108  *
109  * If a parent node is not included in any row, it is regarded that it is the leaf node.
110  * For example, it is valid that the rows with zero children can be deleted.
111  *
112  * Node number is numbered from 1 to n, where n denotes the number of nodes.
113  *
114  * In the program, we deduct the number by 1, as C starts from 0, instead of 1.
115  *
116  */
117 
118 void readFromFile(char * FileName, struct ChildrenNum ** TreeInfo, int n){
119  FILE *fp;
120  struct ChildrenNum * treeInfo;
121  int i, j, num, nodeId;
122 
123 
124  fp=fopen(FileName, "r");
125 
126  if(!fp){
127  printf("\n\n Fatal Error!!!");
128  printf("\n\n Failure in reading the file:%s!", FileName);
129  printf("\n\n The program does not check the correctness of the tree provided in the file: %s!", FileName);
130  return;
131  }
132 
133  treeInfo=(struct ChildrenNum *)malloc(sizeof(struct ChildrenNum)*n);
134 
135  if(!treeInfo){
136  printf("\n Allocation of treeInfo failure!");
137  return;
138  }
139 
140  for(i=0;i<n;i++){
141  treeInfo[i].children_num=0;
142  treeInfo[i].children=NULL;
143  }
144 
145 
146  while (!feof(fp)) {
147 
148  i=-1;num=-1;
149  if ( fscanf(fp, "%d %d", &i, &num)!=2){
150 
151  /*if this is due to extra spaces/breaks etc., we terminate reading the file */
152  if(feof(fp))
153  break;
154 
155  printf("\n For each row, it should has at least two numbers: nodeNum and number of children");
156  return;
157  }
158 
159  if (i>n || i<1){
160  printf("\n The node number should be between [1, %d]!",n);
161  return;
162  }
163 
164  i=i-1;
165  /*i=i-1, as C starts from 0 instead of 1*/
166  if (num>0){
167  treeInfo[i].children_num=num;
168 
169  treeInfo[i].children=(int *)malloc(sizeof(int)*num);
170 
171  if(!treeInfo[i].children){
172  printf("\n Allocation of treeInfo failure!");
173  return;
174  }
175 
176  for(j=0;j<num;j++){
177  if(!fscanf(fp, "%d", &nodeId) ){
178  printf("\n This row should have %d children nodes!", num);
179  return;
180  }
181  else{
182  if (nodeId>n || nodeId<1){
183  printf("\n The node number should be between [1, %d]!", n);
184  return;
185  }
186 
187  treeInfo[i].children[j]=nodeId-1;
188  /*add -1, as C starts from 0 instead of 1*/
189  }
190 
191  }
192  }
193  }
194 
195  fclose(fp);
196 
197  /*
198  printf("\n In readFromFile!");
199  for(i=0;i<n;i++){
200  printf("\n %d: %d:",i, treeInfo[i].children_num);
201 
202  for(j=0;j<treeInfo[i].children_num;j++)
203  printf(" %d", treeInfo[i].children[j]);
204  }
205  printf("\n Out of readFromFile!");
206  */
207 
208 
209  *TreeInfo=treeInfo;/*set value for TreeInfo*/
210 }
211 
212 
213 /*
214  *
215  * We build the tree in a recursive manner
216  *
217  */
218 void buildTree(struct Node* root, struct ChildrenNum * treeInfo, double *u){
219 
220 
221  struct Node * newNode;
222  struct NodeNum * currentNode;
223  int currentRoot=root->firstNode->node_num;
224  int numberOfChildren=treeInfo[currentRoot].children_num;
225  int i;
226 
227  /* insert the children nodes of the current root
228  */
229  for(i=0;i<numberOfChildren;i++){
230 
231 
232  newNode=(struct Node *)malloc(sizeof(struct Node));
233  currentNode=(struct NodeNum *)malloc(sizeof(struct NodeNum));
234 
235  if(!newNode){
236  printf("\n Allocation in buildTree failure!");
237  return;
238  }
239 
240  if(!currentNode){
241  printf("\n Allocation in buildTree failure!");
242  return;
243  }
244 
245 
246  newNode->flag=0;
247  newNode->m=u[treeInfo[currentRoot].children[i]];
248  newNode->num=1;
249  newNode->child=NULL;
250 
251  currentNode->node_num=treeInfo[currentRoot].children[i];
252  currentNode->next=NULL;
253  newNode->firstNode=newNode->lastNode=currentNode;
254 
255  /*
256  * insert newnode to be the children nodes of root
257  *
258  */
259  newNode->brother=root->child;
260  root->child=newNode;
261 
262  /*
263  * treat newNode as the root, and add its children
264  *
265  */
266 
267  buildTree(newNode, treeInfo, u);
268  }
269 }
270 
271 /*
272  * initilize the root, which means that the tree is built by this function.
273  * as the root is the starting point of a tree
274  *
275  * we use the input file for building the tree
276  */
277 
278 void initializeRoot(struct Node ** Root, char * FileName, double *u, int rootNum, int n){
279 
280  struct NodeNum * currentNode;
281  struct Node *root;
282  struct ChildrenNum * treeInfo;
283  int i;
284 
285  /*read the from the file to construct treeInfo*/
286  readFromFile(FileName, &treeInfo, n);
287 
288  if(rootNum>n || rootNum <1){
289  printf("\n The node number of the root should be between [1, %d]!", n);
290  return;
291  }
292 
293  rootNum=rootNum-1;
294  /*add -1, as C starts from 0 instead of 1*/
295 
296  root=(struct Node *)malloc(sizeof(struct Node));
297  currentNode=(struct NodeNum *)malloc(sizeof(struct NodeNum));
298 
299  if(!root){
300  printf("\n Allocation in computeGroups failure!");
301  return;
302  }
303 
304  if(!currentNode){
305  printf("\n Allocation in computeGroups failure!");
306  return;
307  }
308 
309 
310  root->flag=0;
311  root->m=u[rootNum];
312  root->num=1;
313  root->brother=root->child=NULL;
314 
315  currentNode->node_num=rootNum;
316  currentNode->next=NULL;
317  root->firstNode=root->lastNode=currentNode;
318 
319  /*build the tree using buildTree*/
320  buildTree(root, treeInfo, u);
321 
322  /*free treeInfo*/
323  for(i=0;i<n;i++){
324  if (treeInfo[i].children_num)
325  free(treeInfo[i].children);
326  }
327  free(treeInfo);
328 
329  *Root=root;
330 }
331 
332 
333 
334 /*
335  * initilize the root for the full binary tree
336  *
337  * We do not need to give the input file, as binary tree is very special
338  */
339 
340 void initializeRootBinary(struct Node ** Root, double *u, int n){
341 
342  struct NodeNum * currentNode;
343  struct Node *root;
344  struct ChildrenNum * treeInfo;
345  int rootNum=1;
346  int i, half=n/2;
347 
348  /*
349  *
350  * readFromFile(FileName, &treeInfo, n);
351  *
352  * Replace the above function.
353  *
354  * we build treeInfo here directly using the special structure
355  *
356  */
357 
358  treeInfo=(struct ChildrenNum *)malloc(sizeof(struct ChildrenNum)*n);
359  if(!treeInfo){
360  printf("\n Allocation of treeInfo failure!");
361  return;
362  }
363 
364  for(i=0;i<half;i++){
365  treeInfo[i].children_num=2;
366  treeInfo[i].children=(int *)malloc(sizeof(int)*2);
367  treeInfo[i].children[0]=2*i+1;
368  treeInfo[i].children[1]=2*i+2;
369  }
370 
371  for(i=half;i<n;i++){
372  treeInfo[i].children_num=0;
373  treeInfo[i].children=NULL;
374  }
375 
376 
377  rootNum=rootNum-1;
378  /*add -1, as C starts from 0 instead of 1*/
379 
380  root=(struct Node *)malloc(sizeof(struct Node));
381  currentNode=(struct NodeNum *)malloc(sizeof(struct NodeNum));
382 
383  if(!root){
384  printf("\n Allocation in computeGroups failure!");
385  return;
386  }
387 
388  if(!currentNode){
389  printf("\n Allocation in computeGroups failure!");
390  return;
391  }
392 
393 
394  root->flag=0;
395  root->m=u[rootNum];
396  root->num=1;
397  root->brother=root->child=NULL;
398 
399  currentNode->node_num=rootNum;
400  currentNode->next=NULL;
401  root->firstNode=root->lastNode=currentNode;
402 
403  /*build the tree using buildTree*/
404  buildTree(root, treeInfo, u);
405 
406  /*free treeInfo*/
407  for(i=0;i<half;i++){
408  free(treeInfo[i].children);
409  }
410  free(treeInfo);
411 
412  *Root=root;
413 }
414 
415 
416 /*
417  * initilize the root for the full binary tree
418  *
419  * We do not need to give the input file, as tree of depth 1 is very special
420  */
421 
422 void initializeRootDepth1(struct Node ** Root, double *u, int n){
423 
424  struct NodeNum * currentNode;
425  struct Node *root;
426  struct ChildrenNum * treeInfo;
427  int rootNum=1;
428  int i;
429 
430  /*
431  * readFromFile(FileName, &treeInfo, n);
432  *
433  * we build treeInfo here, using the special structure of the tree with depth 1
434  *
435  */
436 
437  treeInfo=(struct ChildrenNum *)malloc(sizeof(struct ChildrenNum)*n);
438  if(!treeInfo){
439  printf("\n Allocation of treeInfo failure!");
440  return;
441  }
442 
443  for(i=0;i<n;i++){
444  treeInfo[i].children_num=0;
445  treeInfo[i].children=NULL;
446  }
447 
448  /*process the root*/
449  if (n>1){
450  treeInfo[0].children_num=n-1;
451  treeInfo[0].children=(int *)malloc(sizeof(int)*(n-1));
452  for(i=1;i<n;i++)
453  treeInfo[0].children[i-1]=i;
454  }
455 
456  rootNum=rootNum-1;
457  /*add -1, as C starts from 0 instead of 1*/
458 
459  root=(struct Node *)malloc(sizeof(struct Node));
460  currentNode=(struct NodeNum *)malloc(sizeof(struct NodeNum));
461 
462  if(!root){
463  printf("\n Allocation in computeGroups failure!");
464  return;
465  }
466 
467  if(!currentNode){
468  printf("\n Allocation in computeGroups failure!");
469  return;
470  }
471 
472 
473  root->flag=0;
474  root->m=u[rootNum];
475  root->num=1;
476  root->brother=root->child=NULL;
477 
478  currentNode->node_num=rootNum;
479  currentNode->next=NULL;
480  root->firstNode=root->lastNode=currentNode;
481 
482  /*build the tree using buildTree*/
483  buildTree(root, treeInfo, u);
484 
485  /*free treeInfo*/
486  if(n>1)
487  free(treeInfo[0].children);
488  free(treeInfo);
489 
490  *Root=root;
491 }
492 
493 
494 
495 /*
496  * merge root with maxNode
497  */
498 void merge(struct Node * root, struct Node * maxNode ){
499  struct Node * childrenNode, *maxNodeChild;
500 
501  root->m= (root->m* root->num + maxNode->m *maxNode->num)/(root->num + maxNode->num);
502  root->num+=maxNode->num;
503  root->lastNode->next=maxNode->firstNode;
504  root->lastNode=maxNode->lastNode;
505 
506  /*
507  * update the brother list of maxNode (when removing maxNode)
508  *
509  */
510  if (root->child==maxNode){
511  root->child=maxNode->brother;
512  }
513  else{
514  childrenNode=root->child;
515 
516  while(childrenNode->brother!=maxNode){
517  childrenNode=childrenNode->brother;
518  }
519  /*childrenNode's brother is maxNode*/
520  childrenNode->brother=maxNode->brother;
521  }
522 
523 
524  /*
525  * change the children of maxNode to the children of root
526  */
527  maxNodeChild=maxNode->child;
528  if (maxNodeChild){
529  /*if maxNode has at least a child*/
530 
531  while(maxNodeChild->brother)
532  maxNodeChild=maxNodeChild->brother;
533  /*maxNodeChild points to the last child of maxNode*/
534 
535  maxNodeChild->brother=root->child;
536  root->child=maxNode->child;
537  }
538 
539  /*
540  * remove maxNode from the children list of root
541  */
542  free(maxNode);
543 
544 }
545 
546 
547 
548 /*
549  * compute the maximal mean for each node
550  *
551  */
552 
553 void computeMaximalMean(struct Node * root){
554  struct Node * childrenNode, *maxNode;
555  double mean;
556 
557  /*if root already points to a leaf node, we do nothing*/
558  if(!root->child){
559 
560  /*the value of a maximal root-tree is non-negative*/
561  if (root->m <0)
562  root->m =0;
563 
564  root->flag=1;
565  return;
566  }
567 
568  /*the following loop corresponds to line 5-20 of the algorithm*/
569  while(1){
570 
571  childrenNode=root->child;
572  if(!childrenNode){
573 
574  if (root->m <0)
575  root->m =0;
576 
577  root->flag=1;
578  return;
579  }
580 
581  /*we note that, childrenNode->m >=0*/
582 
583  mean=0;
584 
585  /*visit all its children nodes, to get the maximal "mean" and corresponding maxNode*/
586  while(childrenNode){
587 
588  /*if the maximal root-tree at childrenNode is not computed, we compute it*/
589  if (!childrenNode->flag)
590  computeMaximalMean(childrenNode);
591 
592  if (childrenNode->m >= mean){
593  mean=childrenNode->m;
594  maxNode=childrenNode;
595  }
596 
597  childrenNode=childrenNode->brother;
598  }
599 
600  if ( (root->m <= 0) && (mean==0) ){
601  /* merge root with all its children, in this case,
602  * its children is a super-node
603  * (thus does not has any other children, due to merge)*/
604 
605  childrenNode=root->child;
606  while(childrenNode){
607  merge(root, childrenNode);
608  childrenNode=root->child;
609  }
610 
611  root->m =0;
612  root->flag=1;
613  return;
614  }
615 
616  if (root->m > mean){
617 
618  root->flag=1;
619  return;
620  }
621 
622  merge(root,maxNode);
623  }
624 
625 }
626 
627 
628 
629 /*
630  * compute the maximal mean for each node, without the non-negative constraint
631  *
632  * Composed on November 23, 2011.
633  *
634  */
635 
636 void computeMaximalMean_without_nonnegative(struct Node * root){
637  struct Node * childrenNode, *maxNode;
638  double mean;
639  int mean_flag;
640 
641  /*if root already points to a leaf node, we do nothing*/
642  if(!root->child){
643 
644  /*the value of a maximal root-tree is not necessarily non-negative, when the non-negative constraint is not imposed*/
645 
646  /*
647  The following is removed
648  if (root->m <0)
649  root->m =0;
650  */
651 
652 
653  root->flag=1;
654  return;
655  }
656 
657  /*the following loop corresponds to line 5-20 of the algorithm */
658  while(1){
659 
660  childrenNode=root->child;
661  if(!childrenNode){
662 
663  /*the value of a maximal root-tree is not necessarily non-negative, when the non-negative constraint is not imposed*/
664 
665  /*
666  The following is removed
667 
668  if (root->m <0)
669  root->m =0;
670  */
671 
672  root->flag=1;
673  return;
674  }
675 
676  /*we note that, childrenNode->m >=0 does not necesarily hold.
677  Therefore, for mean, we need to initialize with a small value. We initialize it with the value of its first child node
678  */
679 
680  mean_flag=0; /*0 denotes that "mean" has not been really specified*/
681 
682  /*visit all its children nodes, to get the maximal "mean" and corresponding maxNode*/
683  while(childrenNode){
684 
685  /*if the maximal root-tree at childrenNode is not computed, we compute it*/
686  if (!childrenNode->flag)
687  computeMaximalMean_without_nonnegative(childrenNode);
688 
689  /*if mean has not been specified, let us specify it, and set mean_flag to 1*/
690  if (!mean_flag){
691  mean=childrenNode->m;
692  mean_flag=1;
693  }
694 
695  if (childrenNode->m >= mean){
696  mean=childrenNode->m;
697  maxNode=childrenNode;
698  }
699 
700  childrenNode=childrenNode->brother;
701  }
702 
703  if (root->m > mean){
704 
705  root->flag=1;
706  return;
707  }
708 
709  merge(root,maxNode);
710  }
711 
712 }
713 
714 
715 /*
716  * computeSolution
717  *
718  */
719 
720 
721 void computeSolution(double *x, struct Node *root){
722  struct Node * child;
723  struct NodeNum *currentNode;
724  double mean;
725 
726  if (root){
727  /*
728  * process the root
729  *
730  * set the value for x
731  */
732 
733  mean=root->m;
734 
735  currentNode=root->firstNode;
736  while(currentNode){
737  x[currentNode->node_num]=mean;
738  currentNode=currentNode->next;
739  }
740 
741  /*process the children of root*/
742  child=root->child;
743  while(child){
744  computeSolution(x, child);
745 
746  child=child->brother;
747  }
748  }
749 }
750 
751 /*
752  * traverse the tree
753  * used for debugging the correctness of the code
754  */
755 
756 void traversalTree(struct Node *root){
757  struct Node * child;
758  struct NodeNum *currentNode;
759 
760  if (root){
761  printf("\n\n root->m =%2.5f, num:%d \n Nodes:",root->m,root->num);
762 
763  currentNode=root->firstNode;
764  while(currentNode){
765  printf(" %d ", currentNode->node_num);
766  currentNode=currentNode->next;
767  }
768 
769  printf("\n root: %d, child:", root->m);
770 
771  /*print out the children of root*/
772  child=root->child;
773  while(child){
774  printf(" %d", child->m);
775  child=child->brother;
776  }
777 
778  /*print out the children of children*/
779  child=root->child;
780  while(child){
781  traversalTree(child);
782 
783  child=child->brother;
784  }
785  }
786 }
787 
788 
789 
790 
791 
792 /*
793  * free the dynamic space generated by alloc
794  */
795 
796 void deleteTree(struct Node *root){
797  struct Node *child, *temp;
798  struct NodeNum *currentNode;
799 
800  if (root){
801 
802  child=root->child;
803 
804  while(child){
805 
806  temp=child->brother;
807  /*point to its brother*/
808 
809  deleteTree(child);
810  /*free its chlidren*/
811 
812  child=temp;
813  }
814 
815  /*
816  * free root
817  *
818  * 1. free NodeNum pointed by firstNode and lastNode
819  * 2. free Node
820  */
821  currentNode=root->firstNode;
822  while(currentNode){
823  root->firstNode=currentNode->next;
824  free(currentNode);
825 
826  currentNode=root->firstNode;
827  }
828  root->lastNode=NULL;
829  free(root);
830  }
831 }
832 
833 /*
834  * This is the main function for the general tree
835  *
836  */
837 
838 void orderTree(double *x, char * FileName, double *u, int rootNum, int n){
839  struct Node * root;
840 
841  /*
842  * build the tree using initializeRoot
843  */
844  initializeRoot(&root, FileName, u, rootNum, n);
845 
846  /*
847  printf("\n\n Before computation");
848  traversalTree(root);
849  */
850 
851 
852  /*
853  * compute the maximal average for each node
854  */
855 
856  computeMaximalMean(root);
857 
858 
859  /*compute the solution from the tree*/
860 
861  computeSolution(x, root);
862 
863 
864  /*
865  printf("\n\n After computation");
866  traversalTree(root);
867  */
868 
869 
870  /* delete the tree
871  */
872  deleteTree(root);
873 }
874 
875 
876 /*
877  * This is the main function for the general tree, without the non-negative constraint
878  *
879  */
880 
881 void orderTree_without_nonnegative(double *x, char * FileName, double *u, int rootNum, int n){
882  struct Node * root;
883 
884  /*
885  * build the tree using initializeRoot
886  */
887  initializeRoot(&root, FileName, u, rootNum, n);
888 
889  /*
890  printf("\n\n Before computation");
891  traversalTree(root);
892  */
893 
894 
895  /*
896  * compute the maximal average for each node
897  */
898 
899  computeMaximalMean_without_nonnegative(root);
900 
901 
902  /*compute the solution from the tree*/
903 
904  computeSolution(x, root);
905 
906 
907  /*
908  printf("\n\n After computation");
909  traversalTree(root);
910  */
911 
912 
913  /* delete the tree
914  */
915  deleteTree(root);
916 }
917 
918 
919 
920 /*
921  * This is the main function for the full binary tree
922  *
923  */
924 
925 void orderTreeBinary(double *x, double *u, int n){
926  struct Node * root;
927 
928  /*
929  * build the tree using initializeRootBinary for the binary tree
930  *
931  * please make sure that n=2^{depth +1} -1
932  *
933  */
934 
935  initializeRootBinary(&root, u, n);
936 
937  /*
938  printf("\n\n Before computation");
939  traversalTree(root);
940  */
941 
942 
943  /*
944  * compute the maximal average for each node
945  */
946 
947  computeMaximalMean(root);
948 
949 
950  /*compute the solution from the tree*/
951 
952  computeSolution(x, root);
953 
954 
955  /*
956  printf("\n\n After computation");
957  traversalTree(root);
958  */
959 
960 
961  /* delete the tree
962  */
963  deleteTree(root);
964 }
965 
966 
967 /*
968  * This is the main function for the tree with depth 1
969  *
970  */
971 
972 void orderTreeDepth1(double *x, double *u, int n){
973  struct Node * root;
974 
975  /*
976  * build the tree using initializeRootDepth1 for the tree with depth 1
977  *
978  */
979 
980  initializeRootDepth1(&root, u, n);
981 
982  /*
983  printf("\n\n Before computation");
984  traversalTree(root);
985  */
986 
987 
988  /*
989  * compute the maximal average for each node
990  */
991 
992  computeMaximalMean(root);
993 
994 
995  /*compute the solution from the tree*/
996 
997  computeSolution(x, root);
998 
999 
1000  /*
1001  printf("\n\n After computation");
1002  traversalTree(root);
1003  */
1004 
1005 
1006  /* delete the tree
1007  */
1008  deleteTree(root);
1009 }
1010 #endif //USE_GPL_SHOGUN
1011 #endif /* ----- #ifndef ORDERTREE_SLEP ----- */
#define IGNORE_IN_CLASSLIST
Definition: orderTree.h:21

SHOGUN Machine Learning Toolbox - Documentation