Skip to main content

extremitypathfinder

CI status documentation status latest version on PyPI supported Python versions total PyPI downloads pre-commit code style: ruff

Python package for fast geometric shortest path computation in 2D multi-polygon or grid environments based on visibility graphs.

Exact Euclidean shortest paths with pip install, on the polygons you already have: touching and overlapping polygons and grids are used as they are, with well-defined and tested behaviour at contacts and other edge cases (what sets it apart).

shortest path through a polygon environment

Features

  • Exact shortest paths: the Euclidean shortest path between any two points of the free space, not an approximation on a grid or mesh.

  • Fast repeated queries: the visibility graph of an environment is computed once, each query then only connects its start and goal to it. Only the protruding corners (“extremities”) become graph nodes, which keeps the graph small.

  • Polygon environments: a boundary polygon with holes, or holes only (unbounded environments). Polygons may touch and overlap each other. Touching obstacles form a wall that paths cannot pass. The polygons are used directly: no triangulation or navigation mesh is needed.

  • Grids: convert a grid with blocked cells into a polygon environment.

  • Shapely and GeoJSON input (optional): pass Shapely geometries, GeoJSON or GeoPandas geometries directly. Agents with a size keep a clearance to the obstacles when these are inflated with Shapely (documented recipe).

  • Well-defined edge cases: touching obstacles, points on edges and collinear vertices follow one set of rules. The floating point decisions are audited against exact arithmetic, the results are identical with and without Numba.

  • Few dependencies: only NumPy. Optional Numba acceleration, export of the visibility graph to NetworkX.

  • Extras: input validation, plotting (Matplotlib), saving prepared environments to a file, and a command line interface.

Installation

pip install extremitypathfinder

With the optional Numba extra for a significant speedup (larger installation, initial compilation time):

pip install "extremitypathfinder[numba]"

Python 3.12 or newer is required (CI tests CPython 3.12–3.15). Dependencies: NumPy >=2.3.3,<3 (NetworkX 3.x with the optional networkx extra). Cf. supported versions and dependencies for the support policy.

Quick Start

Polygon environment

from extremitypathfinder import PolygonEnvironment

# the boundary polygon (clockwise or counter clockwise vertex numbering)
boundary_coordinates = [(0.0, 0.0), (10.0, 0.0), (9.0, 5.0), (10.0, 10.0), (0.0, 10.0)]
# the holes (obstacles)
list_of_holes = [
    [
        (3.0, 7.0),
        (5.0, 9.0),
        (4.5, 7.0),
        (5.0, 4.0),
    ],
]
# computes the visibility graph once
environment = PolygonEnvironment(boundary_coordinates, list_of_holes)

# fast consecutive queries
path, length = environment.find_shortest_path((4.5, 1.0), (4.0, 8.5))
# path: [(4.5, 1.0), (3.0, 7.0), (4.0, 8.5)], length: 7.987...

path is [] and length is None when there is no path between start and goal. The input polygons are validated by default (self intersections, overlapping edges, …) and invalid input raises a ValueError. The validation costs little compared to the preparation of the environment. For trusted input it can be skipped (validate=False).

Grid environment

Coordinates refer to the corners of the grid cells, i.e. cell (x, y) spans [x, x+1] x [y, y+1]:

size_x, size_y = 5, 3
obstacle_iter = [(2, 1), (3, 1)]  # blocked grid cells (x, y)
environment = PolygonEnvironment.from_grid(size_x, size_y, obstacle_iter)
path, length = environment.find_shortest_path((0.5, 0.5), (4.5, 2.5))
# path: [(0.5, 0.5), (2.0, 2.0), (4.5, 2.5)], length: 4.670...

Command line

Environments stored as JSON (cf. example.json) can be queried from the command line:

extremitypathfinder ./example.json -s 2.5 3.2 -g 7.9 6.8

Documentation

The documentation covers:

Citing

If you use extremitypathfinder in your research, please cite it. The citation metadata is in CITATION.cff: GitHub converts it into APA and BibTeX (“Cite this repository” in the sidebar of the repository). Please cite the version you used.

Contributing and License

Contributions are welcome: see the contribution guidelines and the issue tracker. Questions and requests for help go to the issue tracker as well.

extremitypathfinder is distributed under the terms of the MIT license (LICENSE).

Also see: GitHub, PyPI, Changelog

Metadata

Release files for extremitypathfinder 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for extremitypathfinder 4.0.0
File Size Uploaded Provenance Actions
extremitypathfinder-4.0.0.tar.gz 171.3 kB Without provenance Details for extremitypathfinder-4.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for extremitypathfinder 4.0.0
File Interpreter ABI Platform Actions
extremitypathfinder-4.0.0-py3-none-any.whl Python 3 none any Details for extremitypathfinder-4.0.0-py3-none-any.whl

Total release size: 235.4 kB

Release files / extremitypathfinder-4.0.0.tar.gz

Download URL extremitypathfinder-4.0.0.tar.gz
Size 171.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a73e54cbbd9edbe8bfda537fd760453e6f8a06e1ba0cf0987b9bc678cfd265d2
BLAKE2b-256 checksum
How to use checksums
c42aaf977be2076ec952a82c5d27a06bbdf18e29507e584379ae772e158c42d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / extremitypathfinder-4.0.0-py3-none-any.whl

Download URL extremitypathfinder-4.0.0-py3-none-any.whl
Size 64.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2ddd52b7a2dc1be41866ed74cac07b4949e532e6401af182d86a861c11609e6
BLAKE2b-256 checksum
How to use checksums
3d8302148261373be3009c71f31a63daa8f5a2d2cd9ff2d918fd7bded5f24490
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for extremitypathfinder 4.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page