45
Try to replace the function code with this one and let me know if it works for you:
function mater_side($p, $m, $a, $ndist)
{
global $fathers, $mothers, $marked, $COIs, $deltaf, $ICknown, $verbose, $nl, $chrono, $paternal_rank, $max_dist;
if (!$m or $ndist > $max_dist) {
return 0;
}
if ($p == $m) {
/* IMPLEX FOUND (node of consanguinity) { for Anim #A */
$already_known = $ICknown[$p];
}
if (!$already_known) {
CONSANG($p);
} // MAIN RECURSION:
$ICp = $COIs[$p]; // we need to know the IC of Parent for Wright's formula
if ($verbose && !$already_known && $ICp > 0.001 * $verbose) {
echo "IC of Animal $p is $ICp$nl";
}
$incr = 1.0 / (1 << $ndist) * (1. + $ICp); // ******** applying WRIGHT's formula ********
// [Note: 1 << $ndist is equal to 2 power $ndist]
$COIs[$a] += $incr; // incrementing the IC of AnimC
if ($a == 0) {
$deltaf[$p] += $incr;
}
/* contribution of Anim #P to IC of Anim #0 */
// if ($verbose && $a == 0 && $incr > 0.0001*$verbose)
// echo "Animal $p is contributing for " . substr ($deltaf[$p], 0, 10) . " to the IC of Animal $a$nl" ;}
else
{
if (!$marked[$m] && $chrono[$m] < $paternal_rank) {
mater_side($p, $fathers[$m], $a, $ndist + 1);
}
mater_side($p, $mothers[$m], $a, $ndist + 1);
}
return 0;
}