Skip to content

Error when running pathfinding multiple times in graph #67

@andreyd41

Description

@andreyd41

Describe the bug
Error when running pathfinding multiple times in graph

To Reproduce

from pathfinding.core.graph import Graph
from pathfinding.finder.dijkstra import DijkstraFinder

graph = Graph(edges=[[0, 1, 1], [1, 0, 1]], bi_directional=False)
finder = DijkstraFinder()
path, _ = finder.find_path(graph.node(0), graph.node(1), graph)
path, _ = finder.find_path(graph.node(0), graph.node(1), graph)

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../python-pathfinding/pathfinding/finder/a_star.py", line 96, in find_path
    return super(AStarFinder, self).find_path(start, end, graph)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../python-pathfinding/pathfinding/finder/finder.py", line 180, in find_path
    self.clean_grid(grid)
  File ".../python-pathfinding/pathfinding/finder/finder.py", line 167, in clean_grid
    grid.cleanup()
    ^^^^^^^^^^^^
AttributeError: 'Graph' object has no attribute 'cleanup'

Expected behavior
Calling pathfinding multiple times should return the correct path each time without errors. Each call should be independent and not affected by previous runs.

Screenshots / Map / Log
.

Environment (please complete the following information):

  • Environment: Ubuntu 24.04
  • Python version: 3.12
  • Pathfinding Version: 1.0.16

Additional context
Apparently Graph doesn't have a cleanup method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions