8000 add sequence diagram to explain dependencies · brean/python-pathfinding@d25775b · GitHub
[go: up one dir, main page]

Skip to content

Commit d25775b

Browse files
committed
add sequence diagram to explain dependencies
1 parent b378696 commit d25775b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ flow:
6969
process_node # calculate new cost for neighboring node
7070
```
7171

72+
Because most algorithms are very similar we use inerhitance to reduce the code, however this makes it a bit harder to understand as you need to jump between the finder implementation and the finder base class, this diagram visualizes the function calls between the AStarFinder and the Finder classes as an example, this flexible aproach allows you to use inheritance to take control of processing the data and extending the algorithm. Note that this is not a classic UML sequence diagram, we just use it for visualation, feel free to suggest a nicer diagram/explaination as new issues.
73+
```mermaid
74+
sequenceDiagram
75+
User ->> AStarFinder: find_path(start, end, grid)
76+
AStarFinder ->> Finder: cleanup() [inheritance]
77+
Finder ->> Grid: cleanup()
78+
Grid ->> Grid: dirty = True
79+
Finder ->> AStarFinder: check_neighbors(start, end, grid, open_list) <br />[from find_path]
80+
AStarFinder ->> Finder: find_neighbors(graph, node) <br />[from check_neighgors]
81+
Finder ->> Grid: neighbors(node, ...)
82+
AStarFinder ->> Finder: process_node(graph, neighbor, node, end, open_list, open_value)<br />[from check_neighbors]
83+
Finder ->> Finder: apply_heuristic(self, node_a, node_b, ...)
84+
AStarFinder ->> User: return path, self.runs<br />[from find_path]
85+
```
86+
7287
## Testing
7388

7489
You can run the tests locally using pytest. Take a look at the `test`-folder

0 commit comments

Comments
 (0)
0