{"id":26378110,"url":"https://github.com/php-science/pagerank","last_synced_at":"2025-09-05T07:43:22.555Z","repository":{"id":57039938,"uuid":"295793161","full_name":"PHP-Science/PageRank","owner":"PHP-Science","description":":elephant: PageRank implementation in PHP with extendable features (PHP 7.4)","archived":false,"fork":false,"pushed_at":"2020-09-24T18:17:14.000Z","size":36,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-05T12:55:48.871Z","etag":null,"topics":["pagerank","pagerank-algorithm","php"],"latest_commit_sha":null,"homepage":"https://php.science/pagerank/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PHP-Science.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-15T16:53:58.000Z","updated_at":"2024-09-20T10:09:03.000Z","dependencies_parsed_at":"2022-08-24T00:50:54.924Z","dependency_job_id":null,"html_url":"https://github.com/PHP-Science/PageRank","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/PHP-Science/PageRank","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-Science%2FPageRank","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-Science%2FPageRank/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-Science%2FPageRank/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-Science%2FPageRank/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PHP-Science","download_url":"https://codeload.github.com/PHP-Science/PageRank/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PHP-Science%2FPageRank/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273728130,"owners_count":25157136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pagerank","pagerank-algorithm","php"],"created_at":"2025-03-17T04:21:14.751Z","updated_at":"2025-09-05T07:43:22.521Z","avatar_url":"https://github.com/PHP-Science.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\r\nPageRank\r\n\u003c/h1\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\n\t\u003ca href=\"https://github.com/PHP-Science/PageRank/actions\"\u003e\r\n\t\t\u003cimg src=\"https://github.com/php-science/pagerank/workflows/tests/badge.svg\"/\u003e\r\n\t\u003c/a\u003e\r\n\t\u003ca href=\"https://codecov.io/gh/PHP-Science/PageRank\"\u003e\r\n\t\t\u003cimg src=\"https://codecov.io/gh/PHP-Science/PageRank/branch/master/graph/badge.svg\"/\u003e\r\n\t\u003c/a\u003e\r\n\t\u003ca href=\"https://codeclimate.com/github/PHP-Science/PageRank/maintainability\"\u003e\r\n\t    \u003cimg src=\"https://api.codeclimate.com/v1/badges/48a10db2646ad4ce890c/maintainability\" /\u003e\r\n\t\u003c/a\u003e\r\n\t\u003ca href=\"https://scrutinizer-ci.com/g/PHP-Science/PageRank\"\u003e\r\n        \u003cimg src=\"https://scrutinizer-ci.com/g/PHP-Science/PageRank/badges/quality-score.png?b=master\"/\u003e\r\n    \u003c/a\u003e\r\n\t\u003ca href=\"https://packagist.org/packages/php-science/pagerank\"\u003e\r\n        \u003cimg src=\"https://poser.pugx.org/php-science/pagerank/v/stable.svg\"/\u003e\r\n    \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n\u003cp align=\"center\"\u003e\r\nThis source code is an OOP implementation of the PageRank algorithm.\r\n\u003cbr /\u003e\r\n\u003cbr /\u003e\r\n\u003c/p\u003e\r\n\r\n## About\r\n\r\nThis implementation is based on Larry Page's PageRank algorithm. It weights the connections between the nodes in a graph. \r\nIn theory, the nodes can be websites, words, people, etc. As the number of the nodes are increasing the algorithm is \r\nbecoming slower. To scale the size and handle millions of nodes, the accuracy of the calculation can be limited, and the \r\nlong-running calculation can be scheduled in batches using the Strategy OOP pattern in the implementation. \r\n\r\n## Workflow\r\n\r\n* It calculates the initial ranking values. At the first iteration, all the nodes have the same rank.\r\n* Iterates the nodes using the power method/iteration technique over and over again until it reaches the maximum \r\niteration number.\r\n* However, the iteration stops when the ranks are accurate enough even if the max iteration didn't reach its limit.\r\n* The accuracy measured by the float epsilon constant.\r\n* At the end, the algorithm normalizes the ranks between 0 and 1 and then scale them between 1 and 10. The scaling range \r\nis configurable.\r\n* Getting, setting, updating the nodes from the resource is a responsibility of the NodeDataSourceStrategyInterface.\r\n* The package provides a simple implementation of the NodeDataSourceStrategyInterface that only keeps the nodes in the \r\nmemory. Another way of implementing the NodeDataSourceStrategyInterface could be a simple class that uses an ORM to\r\nhandle the node collection.\r\n\r\n## Install\r\n\r\n```\r\ncomposer require php-science/pagerank\r\n```\r\n\r\n## Example\r\n\r\n```php\r\n$dataSource = $this-\u003egetYourDataSource();\r\n\r\n$nodeBuilder = new NodeBuilder();\r\n$nodeCollectionBuilder = new NodeCollectionBuilder();\r\n$strategy = new MemorySourceStrategy(\r\n    $nodeBuilder,\r\n    $nodeCollectionBuilder,\r\n    $dataSource\r\n);\r\n\r\n$rankComparator = new RankComparator();\r\n$ranking = new Ranking(\r\n    $rankComparator,\r\n    $strategy\r\n);\r\n\r\n$normalizer = new Normalizer();\r\n\r\n$pageRankAlgorithm = new PageRankAlgorithm(\r\n    $ranking,\r\n    $strategy,\r\n    $normalizer\r\n);\r\n\r\n$maxIteration = 100;\r\n$nodeCollection = $pageRankAlgorithm-\u003erun($maxIteration);\r\n\r\nvar_dump($nodeCollection-\u003egetNodes());\r\n```\r\n\r\n## Functional Sample\r\n\r\n* test: [Functional test case](https://github.com/PHP-Science/PageRank/blob/master/tests/functional/Service/PageRankAlgorithmTest.php)\r\n* running the test: ```composer test```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-science%2Fpagerank","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-science%2Fpagerank","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-science%2Fpagerank/lists"}