$IncomingThreshold ) $keypages[] = $bs["name"]; if (isset($bs["outgoing"])) if ($bs["outgoing"] > $OutgoingThreshold ) $keypages[] = $bs["name"]; } return $keypages; } function NetworkDegree($b, $DegreeThreshold=0){ $keypages = array(); //done to avoid returning notthing if the theshold is too high foreach ($b as $bs){ if (isset($bs["degree"])) if ($bs["degree"] > $DegreeThreshold ) $keypages[] = $bs["name"]; } return $keypages; } function NetworkLeverageCentrality($b,$Threshold=0){ $keypages = array(); //done to avoid returning notthing if the theshold is too high foreach ($b as $bs){ if (isset($bs["neighboors"])){ $bs["leveragecentrality"] = 0; $sum = 0; $avg=0; foreach($bs["neighboors"] as $neighboor){ $sum += ($bs["degree"] - $b["$neighboor"]["degree"]) / ($bs["degree"] + $b["$neighboor"]["degree"]); $avg += $b["$neighboor"]["degree"]; } if ($bs["degree"] > 0){ $avg = $avg / $bs["degree"]; if ($avg > 0){ $bs["leveragecentrality"] = ($sum/$avg) / $bs["degree"]; } } if ($bs["leveragecentrality"] > $Threshold ) $keypages[] = $bs["name"]; } } return $keypages; } function GroupDegreeDistribution($groupname){ $pages = ListPages("/$groupname\./e"); //note that this could be replaced by proper ListPages call $pages = CleanPageList($pages,$groupname); $b = GenerateNetworkFromList($pages); if (empty($b)) return array(); $distribution = array_fill(1,10,0); // has no effect foreach ($b as $node){ $degree = $node["degree"]; if (isset($distribution[$degree])) $distribution[$degree]++; else $distribution[$degree]=1; $sumdeg += $node["degree"]; $sumin += $node["incoming"]; $sumout += $node["outgoing"]; } $avgdeg = $sumdeg / count($b); $avgin = $sumin / count($b); $avgout = $sumout / count($b); /* print "avgdeg = $avgdeg; "; print "avgin = $avgin; "; print "avgout = $avgout; "; strangely equal, probably a mistake there */ ksort($distribution); /* fails to get the proper last key end($distribution); $last_key = key($distribution); print $last_key; for ($i=1;i<$last_key;$i++) if (!(isset($distribution[$i]))) $distribution[$i]=0; */ return array_unique($distribution); } ?>