Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
s8_ivanov_r
AT2019_distance_throug_cities
Commits
dab658c3
Commit
dab658c3
authored
Oct 24, 2019
by
Roberts Ivanovs
Browse files
Added support for total route distance output
parent
fe02949a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
city_dijkstra.py
city_dijkstra.py
+7
-4
No files found.
city_dijkstra.py
View file @
dab658c3
...
...
@@ -23,9 +23,10 @@ def mans_cels(city_1, city_2, matrix, cities, block_tuple_list=None):
Returns
-------
list
list
containing list and a string [[str, str...], str]
The route from the starting city to the end city as a list of strings
containing city names
containing city names. The second element is the total
distance for the route between starting city to end city.
"""
print
(
f
"Finding the route between
{
city_1
}
and
{
city_2
}
"
)
...
...
@@ -96,7 +97,7 @@ def mans_cels(city_1, city_2, matrix, cities, block_tuple_list=None):
break
route
.
reverse
()
return
route
return
(
route
,
str
(
sum_dist
[
end_node
]))
curr_node
=
curr_smallest_id
...
...
@@ -113,7 +114,9 @@ def user_friendly_route_formatter(route):
string
A string formatted for the end user to see
"""
return
"road: "
+
str
(
" uz "
.
join
(
route
))
cities
=
route
[
0
]
distance
=
route
[
1
]
return
"road: "
+
str
(
" uz "
.
join
(
cities
))
+
" in "
+
distance
+
" km."
if
__name__
==
"__main__"
:
matrix_data
=
generate_matrix
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment