A PHP extension for PageRank algorithm

In order to support one of our ongoing projects, I developed a PHP extension for PageRank algorithm to conduct search result re-ranking from a PHP frontend. Using pure PHP to do the algorithm is consuming too much time for real-time response when the scale of re-ranking becomes larger.

This PHP extension uses cblas and atblas libraries to speed up matrix computing. It also applies OpenMP on few places.

The PHP extension on github.

After installing the .so file of this extension, you have a pagerank function in PHP to use.

Usage example:

$array = array(
array('0', '1', 0.5),
array('0', '2', 0.5),
array('2', '0', 0.33333),
array('2', '1', 0.33333),
array('2', '4', 0.33333),
array('3', '4', 0.5),
array('3', '5', 0.5),
array('4', '3', 0.5),
array('4', '5', 0.5),
array('5', '3', 1.0),
);

$pi = array(0.16667, 0.16667, 0.16667, 0.16667, 0.16667, 0.16667);
$v = array(0.16667, 0.16667, 0.16667, 0.16667, 0.16667, 0.16667);
$n = 6;
$alpha = 0.9;
$threshold = 0.00000001;

print_r(pagerank($pi, $array, $v, $n, $alpha, $threshold));

?>