Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/NetworkTopology/topologie-gen.php

    r548 r873  
    66global $Database, $debug;
    77
    8 if(array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
     8if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];
    99else $debug = 0;
    1010//$debug = 0;
     
    110110        $markskip = 0;
    111111      }
    112     } while($level >= 1);
     112    } while ($level >= 1);
    113113  }
    114114
     
    128128      $Database->query("INSERT INTO NetworkTopology (Host, Depth, Pos, First, Last) '.
    129129        'VALUES (".$node->index.','.$node->level.','.$this->calc_pos($node).','.$first.','.$last.");");
    130       foreach($node->children as $key => $value) {
     130      foreach ($node->children as $key => $value) {
    131131        $this->store_node($value);
    132132      }
     
    149149        $this->setborder($node->level, $this->border[$node->level+1]+1);
    150150      }
    151       foreach($node->children as $key => $value) {
     151      foreach ($node->children as $key => $value) {
    152152        if ($key == count($node->children)-1) {
    153           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     153          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    154154        }
    155155        $this->left_align($value);
    156156        if ($key == 0) {
    157           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     157          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    158158            $node->pos = $this->border[$node->level+1]-1;
    159159            $this->setborder($node->level, $this->border[$node->level+1]);
     
    174174        $this->setborder($node->level, $this->border[$node->level+1]+1);
    175175      }
    176       for($key=count($node->children)-1;$key>=0;$key--) {
     176      for ($key=count($node->children)-1;$key>=0;$key--) {
    177177        $value = $node->children[$key];
    178178        if ((count($value->children)>0) && count($node->order)>0) {
     
    180180        }
    181181        if ($key == 0) {
    182           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     182          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    183183        }
    184184        $this->right_align($value);
    185185        if ($key == count($node->children)-1) {
    186           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     186          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    187187            $node->rpos = $this->border[$node->level+1]-1;
    188188            $this->setborder($node->level, $this->border[$node->level+1]);
     
    196196  /** Reset construction border **/
    197197  function reset_border() {
    198     foreach($this->border as $key => $value) $this->border[$key] = 0;
     198    foreach ($this->border as $key => $value) $this->border[$key] = 0;
    199199    $this->maxborder = 0;
    200200  }
     
    214214      $target = 0; // Index cílového uzlu
    215215      $lastindex = 0; // Index poslední vydličky
    216       foreach($node->children as $key => $value) {
     216      foreach ($node->children as $key => $value) {
    217217        if (count($value->children)>0) {
    218218          array_push($forkmap,$value);
     
    221221        }
    222222      }
    223       for($i=0;$i<$node->forkcnt-1;$i++) {
    224         for($j=0;$j<count($forkmap);$j++) {
     223      for ($i=0;$i<$node->forkcnt-1;$i++) {
     224        for ($j=0;$j<count($forkmap);$j++) {
    225225          $this->border = $preborder;
    226226          $this->maxborder = $premax;
    227227          $k = 0; // index zpracovávané vydličky
    228           foreach($node->children as $key => $value) {
     228          foreach ($node->children as $key => $value) {
    229229            if (count($value->children)>0) {
    230230              if ($order[$value->index]) {
     
    241241            }
    242242            if ($key == count($node->children)-1) {
    243               if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     243              if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    244244            }
    245245            $this->left_align($value);
    246246            if ($key == 0) {
    247               if($this->border[$node->level] <= $this->border[$node->level+1]) {
     247              if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    248248                $node->pos = $this->border[$node->level+1]-1;
    249249                $this->setborder($node->level, $this->border[$node->level+1]);
     
    272272        $this->setborder($node->level, $this->border[$node->level+1]+1);
    273273      }
    274       foreach($node->children as $key => $value) {
     274      foreach ($node->children as $key => $value) {
    275275        if ((count($value->children)>0) && count($order)>0) {
    276276          $value = $order[$value->index];
    277277        }
    278278        if ($key == count($node->children)-1) {
    279           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     279          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    280280        }
    281281        $this->reorder($value);
    282282        if ($key == 0) {
    283           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     283          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    284284            $node->pos = $this->border[$node->level+1]-1;
    285285            $this->setborder($node->level, $this->border[$node->level+1]);
     
    301301      }
    302302      $forkcnt = 0; // Fork counter
    303       foreach($node->children as $key => $value) {
     303      foreach ($node->children as $key => $value) {
    304304        if ($forkcnt == count($node->children)-1) {
    305           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     305          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    306306        }
    307307        if (count($value->children)>0) {
    308308          $this->left_stub($value);
    309309          if ($forkcnt == 0) {
    310             if($this->border[$node->level] <= $this->border[$node->level+1]) {
     310            if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    311311              $node->pos = $this->border[$node->level+1]-1;
    312312              $this->setborder($node->level, $this->border[$node->level+1]);
     
    335335      $lastindex = 0; // Index poslední vydličky
    336336      $fact = 1; // Faktoriál kombinací vydliček
    337       foreach($node->children as $key => $value) {
     337      foreach ($node->children as $key => $value) {
    338338        if (count($value->children)>0) {
    339339          if ($key>0) $fact = $fact * ($key+1);
     
    343343        }
    344344      }
    345       for($i=0;$i<$node->forkcnt-1;$i++) {
    346         for($j=0;$j<count($forkmap);$j++) {
     345      for ($i=0;$i<$node->forkcnt-1;$i++) {
     346        for ($j=0;$j<count($forkmap);$j++) {
    347347          $this->border = $preborder;
    348348          $this->maxborder = $premax;
    349349          $k = 0; // index zpracovávané vydličky
    350           foreach($node->children as $key => $value) {
     350          foreach ($node->children as $key => $value) {
    351351            if (count($value->children)>0) {
    352352              if ($order[$value->index]) {
     
    363363            }
    364364            if ($key == count($node->children)-1) {
    365               if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     365              if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    366366            }
    367367            $this->left_align($value);
    368368            if ($key == 0) {
    369               if($this->border[$node->level] <= $this->border[$node->level+1]) {
     369              if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    370370                $node->pos = $this->border[$node->level+1]-1;
    371371                $this->setborder($node->level, $this->border[$node->level+1]);
     
    395395        $this->setborder($node->level, $this->border[$node->level+1]+1);
    396396      }
    397       foreach($node->children as $key => $value) {
     397      foreach ($node->children as $key => $value) {
    398398        if ((count($value->children)>0) && count($order)>0) {
    399399          $value = $order[$value->index];
    400400        }
    401401        if ($key == count($node->children)-1) {
    402           if($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
     402          if ($this->border[$node->level] > $this->border[$node->level+1]) $this->setborder($node->level+1, $this->border[$node->level]-1);
    403403        }
    404404        $this->reorder($value);
    405405        if ($key == 0) {
    406           if($this->border[$node->level] <= $this->border[$node->level+1]) {
     406          if ($this->border[$node->level] <= $this->border[$node->level+1]) {
    407407            $node->pos = $this->border[$node->level+1]-1;
    408408            $this->setborder($node->level, $this->border[$node->level+1]);
Note: See TracChangeset for help on using the changeset viewer.