|
|
@@ -2417,7 +2417,17 @@ class BiAuditPowiazania {
|
|
|
$this->saveToDb($path);
|
|
|
}
|
|
|
|
|
|
- public function findPowiazania($ID, $progress = 0, $steps = 1, $relation = "") {
|
|
|
+ private static function weightCalc($n) {
|
|
|
+ static $weights = [];
|
|
|
+ if (isset($weights[$n])) {
|
|
|
+ $weight = floor(log(($n - 1) / 10) / log(2)) + 1;
|
|
|
+ if ($weight < 1) $weight = 1;
|
|
|
+ $weights[$n] = $weight;
|
|
|
+ }
|
|
|
+ return $weights[$n];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function findPowiazania($ID, $progress = 0, $steps = 1, $relation = "", $weight = 0) {
|
|
|
if (((++$this->step) % 1000000) == 0) {
|
|
|
$progressDiff = $progress - $this->lastProgress_slowCheck;
|
|
|
if ($progressDiff < 0.00005) {
|
|
|
@@ -2468,8 +2478,12 @@ class BiAuditPowiazania {
|
|
|
if (isset($this->path[$node['ID']])) return false;
|
|
|
return true;
|
|
|
}));
|
|
|
+
|
|
|
$count = count($nodes);
|
|
|
- foreach ($nodes as $i => $node) $this->findPowiazania($node['ID'], ($progress + ($i / ($count * $steps))), ($count * $steps), $node['RELATION_ID']);
|
|
|
+ $weight += self::weightCalc($count);
|
|
|
+ if ($weight <= $this->maxDepth) {
|
|
|
+ foreach ($nodes as $i => $node) $this->findPowiazania($node['ID'], ($progress + ($i / ($count * $steps))), ($count * $steps), $node['RELATION_ID'], $weight);
|
|
|
+ }
|
|
|
|
|
|
array_pop($this->path);
|
|
|
}
|