Skip to content

Commit

Permalink
Move astar example
Browse files Browse the repository at this point in the history
  • Loading branch information
fizzlebert committed Feb 23, 2018
1 parent de7ad2b commit dd30a8d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 15 additions & 0 deletions astar-example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from astar import Astar
import time
start_time = time.time()

graph = Astar()

graph.add_node("a", {"c": 6, "b": 9, "euclidean": 6})
graph.add_node("b", {"a": 9, "f": 7, "euclidean": 4})
graph.add_node("c", {"e": 6, "d": 10, "euclidean": 6})
graph.add_node("d", {"c": 10, "f": 4, "euclidean": 4})
graph.add_node("e", {"f": 9, "c": 6, "euclidean": 3})
graph.add_node("f", {"d": 6, "e": 9, "euclidean": 0})

print("Path:", (graph.shortest_path("a", "f")))
print("Finished in:", (time.time() - start_time))
13 changes: 0 additions & 13 deletions astar.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,3 @@ def shortest_path(self, start, finish):
path.insert(0, finish)
path.reverse()
return path


graph = Astar()

graph.add_node("a", {"c": 6, "b": 9, "euclidean": 6})
graph.add_node("b", {"a": 9, "f": 7, "euclidean": 4})
graph.add_node("c", {"e": 6, "d": 10, "euclidean": 6})
graph.add_node("d", {"c": 10, "f": 4, "euclidean": 4})
graph.add_node("e", {"f": 9, "c": 6, "euclidean": 3})
graph.add_node("f", {"d": 6, "e": 9, "euclidean": 0})

print("Path:", (graph.shortest_path("a", "f")))
print("Finished in:", (time.time() - start_time))

0 comments on commit dd30a8d

Please sign in to comment.