Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
a-star
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Claudio Scheer
a-star
Commits
1afdae7c
Verified
Commit
1afdae7c
authored
4 years ago
by
Claudio Scheer
Browse files
Options
Downloads
Patches
Plain Diff
Update tests
parent
a0b3d261
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/a_star.py
+3
-1
3 additions, 1 deletion
src/a_star.py
src/graph_tests.py
+6
-2
6 additions, 2 deletions
src/graph_tests.py
with
9 additions
and
3 deletions
src/a_star.py
+
3
−
1
View file @
1afdae7c
...
...
@@ -42,6 +42,8 @@ def a_star(graph, start_node, goal_node, heuristic):
graph
,
start_node
,
goal_node
=
get_graph_1
()
path
=
a_star
(
graph
,
start_node
,
goal_node
,
max_cost
)
print
(
f
"
Start node:
{
start_node
.
id
}
. Goal node:
{
goal_node
.
id
}
"
)
print
(
"
-
"
*
5
,
end
=
""
)
print
(
"
Solution plan
"
,
end
=
""
)
print
(
"
-
"
*
5
)
for
x
in
path
:
print
(
x
.
id
)
print
(
"
-
"
*
30
)
This diff is collapsed.
Click to expand it.
src/graph_tests.py
+
6
−
2
View file @
1afdae7c
...
...
@@ -7,12 +7,16 @@ def get_graph_1():
node_2
=
Node
(
2
)
node_3
=
Node
(
3
)
node_4
=
Node
(
4
)
node_5
=
Node
(
5
)
node_6
=
Node
(
6
)
graph
.
set_bidirectional_neighbor
(
node_1
,
node_2
,
1
)
graph
.
set_bidirectional_neighbor
(
node_1
,
node_3
,
1
)
graph
.
set_bidirectional_neighbor
(
node_2
,
node_4
,
1
)
graph
.
set_bidirectional_neighbor
(
node_3
,
node_4
,
1
)
graph
.
set_bidirectional_neighbor
(
node_3
,
node_5
,
1
)
graph
.
set_bidirectional_neighbor
(
node_5
,
node_6
,
1
)
graph
.
add_nodes
([
node_1
,
node_2
,
node_3
,
node_4
])
graph
.
add_nodes
([
node_1
,
node_2
,
node_3
,
node_4
,
node_5
,
node_6
])
return
graph
,
node_1
,
node_
4
return
graph
,
node_1
,
node_
6
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment