Ejemplo n.º 1
0
                 while (!isset($tree_list[$r->GetLabel()])) {
                     $r = $r->GetAncestor();
                 }
                 $depth += count($tree_list[$r->GetLabel()]);
             }
             $q->SetAttribute('depth', $depth);
             if (!isset($layers[$depth])) {
                 $layers[$depth] = array();
             }
             $layers[$depth][] = $q->GetLabel();
         } else {
             $depth = $anc->GetAttribute('depth');
             $q->SetAttribute('depth', $depth);
         }
     }
     $q = $p->Next();
 }
 /*
 echo '<pre>';
 $t->Dump();
 
 echo $t->WriteDot();
 
 print_r($tree_list);
 
 print_r($layers);
 echo '</pre>';
 */
 // Traverse in preorder...
 // display trees
 foreach ($layers as $layer_number => $taxids_in_this_layer) {
Ejemplo n.º 2
0
 function CalcCoordinates()
 {
     $this->max_path_length = 0.0;
     $this->t->GetRoot()->SetAttribute('path_length', $this->t->GetRoot()->GetAttribute('edge_length'));
     // Get path lengths
     $n = new PreorderIterator($this->t->getRoot());
     $q = $n->Begin();
     while ($q != NULL) {
         $d = $q->GetAttribute('edge_length');
         if ($d < 1.0E-5) {
             $d = 0.0;
         }
         if ($q != $this->t->GetRoot()) {
             $q->SetAttribute('path_length', $q->GetAncestor()->GetAttribute('path_length') + $d);
         }
         $this->max_path_length = max($this->max_path_length, $q->GetAttribute('path_length'));
         $q = $n->Next();
     }
     $leaves = $this->t->GetNumLeaves();
     $this->leaf_count = 0;
     $n = new NodeIterator($this->t->getRoot());
     $q = $n->Begin();
     while ($q != NULL) {
         if ($q->IsLeaf()) {
             $this->CalcLeaf($q);
         } else {
             $this->CalcInternal($q);
         }
         $q = $n->Next();
     }
 }