{"id":19745732,"url":"https://github.com/brean/python-pathfinding","last_synced_at":"2025-05-16T18:10:40.762Z","repository":{"id":29185689,"uuid":"32716626","full_name":"brean/python-pathfinding","owner":"brean","description":"Implementation of common pathfinding algorithms","archived":false,"fork":false,"pushed_at":"2025-05-03T08:24:01.000Z","size":478,"stargazers_count":340,"open_issues_count":21,"forks_count":67,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-03T08:45:05.018Z","etag":null,"topics":["algorithm","obstacle","pathfinding","pathfinding-algorithm","python","python-pathfinding","python3"],"latest_commit_sha":null,"homepage":"https://brean.github.io/svelte-pyscript-pathfinding","language":"Python","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/brean.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-03-23T07:17:56.000Z","updated_at":"2025-05-03T08:24:04.000Z","dependencies_parsed_at":"2023-10-04T17:18:51.388Z","dependency_job_id":"ff9475d7-4b0d-4932-b955-caed775451ff","html_url":"https://github.com/brean/python-pathfinding","commit_stats":{"total_commits":123,"total_committers":12,"mean_commits":10.25,"dds":"0.26016260162601623","last_synced_commit":"759c5c0b78280ec42532f22ea28da0a1ee4b5194"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brean%2Fpython-pathfinding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brean%2Fpython-pathfinding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brean%2Fpython-pathfinding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brean%2Fpython-pathfinding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brean","download_url":"https://codeload.github.com/brean/python-pathfinding/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"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","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":["algorithm","obstacle","pathfinding","pathfinding-algorithm","python","python-pathfinding","python3"],"created_at":"2024-11-12T02:11:05.478Z","updated_at":"2025-05-16T18:10:40.739Z","avatar_url":"https://github.com/brean.png","language":"Python","readme":"# python-pathfinding\n\nPathfinding algorithms for python 3.\n\nCurrently there are 7 path-finders bundled in this library, namely:\n\n- A\\*\n- Dijkstra\n- Best-First\n- Bi-directional A\\*\n- Breadth First Search (BFS)\n- Iterative Deeping A\\* (IDA\\*)\n- Minimum Spanning Tree (MSP)\n\nDijkstra and A\\* take the weight of the fields on the map into account.\n\n![MIT License](https://img.shields.io/github/license/brean/python-pathfinding)\n![PyPI](https://img.shields.io/pypi/v/pathfinding)\n\n_If you are still using python 2 take a look at the (unmaintained) [python2-branch](https://github.com/brean/python-pathfinding/tree/python2)._\n\n## Installation\n\nThis library is provided by pypi, so you can just install the current stable version using pip:\n\n```python\npip install pathfinding\n```\n\nsee [pathfinding on pypi](https://pypi.org/project/pathfinding/)\n\n## Usage examples\n\nFor usage examples with detailed descriptions take a look at the [docs](docs/) folder, also take a look at the [test/](test/) folder for more examples, e.g. how to use pandas.\n\n*image_pathfinding.py* in the `examples/`-folder provides an example how to load an image with a start and goal point. You can all it with an input and output file like this:\n```\ncd examples/\npython3 image_pathfinding.py -i map.png -o foo.png\n```\n\n## Rerun the algorithm\n\nWhile running the pathfinding algorithm it might set values on the nodes. Depending on your path finding algorithm things like calculated distances or visited flags might be stored on them. So if you want to run the algorithm in a loop you need to clean the grid first (see `Grid.cleanup`). Please note that because cleanup looks at all nodes of the grid it might be an operation that can take a bit of time!\n\n## Implementation details\n\nAll pathfinding algorithms in this library are inheriting the Finder class. It has some common functionality that can be overwritten by the implementation of a path finding algorithm.\n\nThe normal process works like this:\n\n1. You call `find_path` on one of your finder implementations.\n1. `init_find` instantiates the `open_list` and resets all values and counters.\n1. The main loop starts on the `open_list`. This list gets filled with all nodes that will be processed next (e.g. all current neighbors that are walkable). For this you need to implement `check_neighbors` in your own finder implementation.\n1. For example in A\\*s implementation of `check_neighbors` you first want to get the next node closest from the current starting point from the open list. the `next_node` method in Finder does this by giving you the node with a minimum `f`-value from the open list, it closes it and removes it from the `open_list`.\n1. if this node is not the end node we go on and get its neighbors by calling `find_neighbors`. This just calls `grid.neighbors` for most algorithms.\n1. If none of the neighbors are the end node we want to process the neighbors to calculate their distances in `process_node`\n1. `process_node` calculates the cost `f` from the start to the current node using the `calc_cost` method and the cost after calculating `h` from `apply_heuristic`.\n1. finally `process_node` updates the open list so `find_path` can run `check_neighbors` on it in the next node in the next iteration of the main loop.\n\nflow:\n\n```pseudo\n  find_path\n    init_find  # (re)set global values and open list\n    check_neighbors  # for every node in open list\n      next_node  # closest node to start in open list\n      find_neighbors  # get neighbors\n      process_node  # calculate new cost for neighboring node\n```\n\n## Testing\n\nYou can run the tests locally using pytest. Take a look at the `test`-folder\n\nYou can follow below steps to setup your virtual environment and run the tests.\n\n```bash\n# Go to repo\ncd python-pathfinding\n\n# Setup virtual env and activate it - Mac/Linux for windows use source venv/Scripts/activate\npython3 -m venv venv\nsource venv/bin/activate\n\n# Install test requirements\npip install -r test/requirements.txt\n\n# Run all the tests\npytest\n```\n\n## Contributing\n\nPlease use the [issue tracker](https://github.com/brean/python-pathfinding/issues) to submit bug reports and feature requests. Please use merge requests as described [here](/CONTRIBUTING.md) to add/adapt functionality.\n\n## License\n\npython-pathfinding is distributed under the [MIT license](https://opensource.org/licenses/MIT).\n\n## Maintainer\n\nAndreas Bresser, self@andreasbresser.de\n\n## Authors / Contributers\n\nAuthors and contributers are [listed on github](https://github.com/brean/python-pathfinding/graphs/contributors).\n\nInspired by [Pathfinding.JS](https://github.com/qiao/PathFinding.js)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrean%2Fpython-pathfinding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrean%2Fpython-pathfinding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrean%2Fpython-pathfinding/lists"}