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

SHOGUN 机器学习工具包 - 项目文档