mirror of
https://github.com/mfocko/blog.git
synced 2024-11-22 04:53:47 +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
|
_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:
|
map and our algorithm has finished in an instant with the following output:
|
||||||
```
|
```
|
||||||
|
Normal cost: 1
|
||||||
|
Vortex cost: 5
|
||||||
Graph:
|
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
|
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.
|
change their cost to `-1` then. Let's check what's the fastest path to the cell.
|
||||||
```
|
```
|
||||||
|
Normal cost: 1
|
||||||
|
Vortex cost: -1
|
||||||
Graph:
|
Graph:
|
||||||
#############
|
#############
|
||||||
#..#..*.*.**#
|
#..#..*.*.**#
|
||||||
|
@ -239,6 +243,8 @@ auto bf_finite(const graph& g, const vertex_t& source,
|
||||||
|
|
||||||
And we get the following result:
|
And we get the following result:
|
||||||
```
|
```
|
||||||
|
Normal cost: 1
|
||||||
|
Vortex cost: -1
|
||||||
Graph:
|
Graph:
|
||||||
#############
|
#############
|
||||||
#..#..*.*.**#
|
#..#..*.*.**#
|
||||||
|
|
Loading…
Reference in a new issue