mirror of
https://github.com/mfocko/blog.git
synced 2024-12-22 05:51:26 +01:00
algorithms(bf-to-astar): normalize the output
Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
parent
a1f871ffb8
commit
39213f1536
1 changed files with 6 additions and 0 deletions
|
@ -107,6 +107,8 @@ finding the path `u → x1 → … → xn → v` to subproblems
|
|||
_Is our solution correct?_ It appears to be correct… We have rather complicated
|
||||
map and our algorithm has finished in an instant with the following output:
|
||||
```
|
||||
Normal cost: 1
|
||||
Vortex cost: 5
|
||||
Graph:
|
||||
#############
|
||||
#..#..*.*.**#
|
||||
|
@ -129,6 +131,8 @@ We can play around a bit with it. The `*` cells can be even vortices that pull
|
|||
you in with a negative price and let you _propel_ yourself out :wink: Let's
|
||||
change their cost to `-1` then. Let's check what's the fastest path to the cell.
|
||||
```
|
||||
Normal cost: 1
|
||||
Vortex cost: -1
|
||||
Graph:
|
||||
#############
|
||||
#..#..*.*.**#
|
||||
|
@ -239,6 +243,8 @@ auto bf_finite(const graph& g, const vertex_t& source,
|
|||
|
||||
And we get the following result:
|
||||
```
|
||||
Normal cost: 1
|
||||
Vortex cost: -1
|
||||
Graph:
|
||||
#############
|
||||
#..#..*.*.**#
|
||||
|
|
Loading…
Reference in a new issue