Esempio n. 1
0
     }
 }
 /*
 echo '<pre>';
 $t->Dump();
 
 echo $t->WriteDot();
 
 print_r($tree_list);
 echo '</pre>';
 */
 // We now have a tree of trees, we want to assign these to a linear order of layers for drawing.
 // Nodes that have no trees are "ignored"
 $layers = array();
 $depth = 0;
 $p = new PreorderIterator($t->GetRoot());
 $q = $p->Begin();
 while ($q != NULL) {
     if ($q == $t->GetRoot()) {
         // Do any studies map to this node?
         if (isset($tree_list[$q->GetLabel()])) {
             $q->SetAttribute('depth', 0);
             if (!isset($layers[$depth])) {
                 $layers[$depth] = array();
             }
             $layers[$depth][] = $q->GetLabel();
         } else {
             $q->SetAttribute('depth', -1);
         }
     } else {
         $anc = $q->GetAncestor();
Esempio 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();
     }
 }