{"id":37006340,"url":"https://github.com/phgraph/graph","last_synced_at":"2026-01-14T00:45:13.693Z","repository":{"id":37548951,"uuid":"176066306","full_name":"phgraph/graph","owner":"phgraph","description":"modern mathematical graph/network library written in PHP","archived":false,"fork":false,"pushed_at":"2023-04-19T20:08:22.000Z","size":445,"stargazers_count":13,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-16T15:05:58.605Z","etag":null,"topics":["graph-algorithms","graph-search-algorithms","graphviz","php","shortest-path-algorithm"],"latest_commit_sha":null,"homepage":"","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/phgraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-17T06:49:38.000Z","updated_at":"2023-03-04T15:46:45.000Z","dependencies_parsed_at":"2022-08-26T15:30:52.574Z","dependency_job_id":null,"html_url":"https://github.com/phgraph/graph","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/phgraph/graph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phgraph%2Fgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phgraph%2Fgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phgraph%2Fgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phgraph%2Fgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phgraph","download_url":"https://codeload.github.com/phgraph/graph/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phgraph%2Fgraph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["graph-algorithms","graph-search-algorithms","graphviz","php","shortest-path-algorithm"],"created_at":"2026-01-14T00:45:13.015Z","updated_at":"2026-01-14T00:45:13.685Z","avatar_url":"https://github.com/phgraph.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/phgraph/graph.svg?branch=master)](https://travis-ci.org/phgraph/graph)\n[![Coverage Status](https://coveralls.io/repos/github/phgraph/graph/badge.svg?branch=master)](https://coveralls.io/github/phgraph/graph?branch=master)\n[![StyleCI](https://github.styleci.io/repos/176066306/shield?branch=master)](https://github.styleci.io/repos/176066306)\n[![Maintainability](https://api.codeclimate.com/v1/badges/2f1941293e8f431a3c9d/maintainability)](https://codeclimate.com/github/phgraph/graph/maintainability)\n\n# phgraph/graph\n\nPHGraph is a modern mathematical graph/network library written in PHP.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require phgraph/graph\n```\n\n## Usage\n\n### Creation and Search\n\n```php\nuse PHGraph\\Graph;\nuse PHGraph\\Search\\BreadthFirst;\n…\n\n$graph = new Graph;\n$columbus = $graph-\u003enewVertex([\n    'name' =\u003e 'Columbus',\n]);\n$cleveland = $graph-\u003enewVertex([\n    'name' =\u003e 'Cleveland',\n]);\n$cincinnati = $graph-\u003enewVertex([\n    'name' =\u003e 'Cincinnati',\n]);\n\n$columbus-\u003ecreateEdge($cleveland);\n$columbus-\u003ecreateEdge($cincinnati);\n\n$search = new BreadthFirst($cincinnati);\nif ($search-\u003ehasVertex($cleveland)) {\n    echo \"We can get from Cincinnati to Cleveland\\n\";\n} else {\n    echo \"We can’t get from Cincinnati to Cleveland\\n\";\n}\n```\n\n### Graph drawing\n\nThis library has support for visualizing graphs as images using\n[GraphViz](http://www.graphviz.org/) \"Graph Visualization Software\". You will\nneed GraphViz installed on your system for this to work.\n\n```php\nuse PHGraph\\Graph;\nuse PHGraph\\GraphViz\\GraphViz;\n…\n\n$graph = new Graph;\n$columbus = $graph-\u003enewVertex([\n    'name' =\u003e 'Columbus',\n]);\n$cleveland = $graph-\u003enewVertex([\n    'name' =\u003e 'Cleveland',\n]);\n$cincinnati = $graph-\u003enewVertex([\n    'name' =\u003e 'Cincinnati',\n]);\n$columbus-\u003ecreateEdge($cleveland);\n$columbus-\u003ecreateEdge($cincinnati);\n\n$graphviz = new GraphViz($graph);\n// open the image on your system\n$graphviz-\u003edisplay();\n```\n\noutput:\n\n![display output](/example/simple.png?raw=true)\n\n### Algorithms\n\nA graph library is rather boring without the ability to use algorithms on it,\nhere is a list of the currently supported ones:\n\n- [Search](https://en.wikipedia.org/wiki/Graph_traversal)\n  - [Depth first](https://en.wikipedia.org/wiki/Depth-first_search)\n  - [Breadth first](https://en.wikipedia.org/wiki/Breadth-first_search)\n- [Shortest path](https://en.wikipedia.org/wiki/Shortest_path_problem)\n  - [Dijkstra](https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm)\n  - [Moore-Bellman-Ford](https://en.wikipedia.org/wiki/Bellman%E2%80%93Ford_algorithm)\n  - [Least Hops](https://en.wikipedia.org/wiki/Best-first_search)\n- [Minimum Spanning Tree](https://en.wikipedia.org/wiki/Minimum_spanning_tree)\n  - [Kruskal’s algorithm](https://en.wikipedia.org/wiki/Kruskal%27s_algorithm)\n  - [Prim’s algorithm](https://en.wikipedia.org/wiki/Prim%27s_algorithm)\n- [Traveling Salesman Problem](https://en.wikipedia.org/wiki/Travelling_salesman_problem)\n  - [Nearest Neighbor](https://en.wikipedia.org/wiki/Nearest_neighbour_algorithm)\n\n# Development\n\n## Installing dependencies\n\nYou will need [Composer](https://getcomposer.org/) for the development\ndependencies. Once you have that, run the following\n\n```bash\n$ composer install\n```\n\n## Running tests\n\nYou can run the current test suite with the following command\n\n```bash\n$ composer test\n```\n\nFor static analysis of the code run the following\n\n```bash\n$ composer analyse\n```\n\n## Bug Reports\n\nBug reports for the current release version can be opened in this repository’s\n[issue tracker](https://github.com/phgraph/graph/issues).\n\n## Thanks\n\nthis was heavily inspired by [graphp/graph](https://github.com/graphp/graph).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphgraph%2Fgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphgraph%2Fgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphgraph%2Fgraph/lists"}