Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Algoritmer og datastrukturer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Jacob Theisen
Algoritmer og datastrukturer
Commits
484f758d
Commit
484f758d
authored
3 years ago
by
Jacob Theisen
Browse files
Options
Downloads
Patches
Plain Diff
prep
parent
24acbb88
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
ov8/test_env/HM_compressed_text
+0
-0
0 additions, 0 deletions
ov8/test_env/HM_compressed_text
ov9/README.md
+1
-0
1 addition, 0 deletions
ov9/README.md
ov9/program1.py
+50
-3
50 additions, 3 deletions
ov9/program1.py
with
51 additions
and
3 deletions
ov8/test_env/HM_compressed_text
+
0
−
0
View file @
484f758d
No preview for this file type
This diff is collapsed.
Click to expand it.
ov9/README.md
0 → 100644
+
1
−
0
View file @
484f758d
#python3 program1.py -a/-n
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ov9/program1.py
+
50
−
3
View file @
484f758d
from
math
import
inf
import
sys
class
int_points
(
object
):
def
__init__
(
self
,
id
,
type
,
name
):
...
...
@@ -20,6 +21,14 @@ class edges (object):
self
.
lenght
=
lenght
self
.
speed
=
speed
class
results
(
object
):
def
__init__
(
self
,
node
,
dist
,
visited
):
self
.
node
=
node
self
.
dist
=
dist
self
.
visited
=
visited
#prep nodes
with
open
(
'
./test_files/noder.txt
'
,
'
r
'
)
as
file
:
node_file
=
file
.
read
()
...
...
@@ -32,7 +41,7 @@ for i in range(0, len(node_file), 3):
#nodenr breddegrad lengdegrad
node_arr
.
append
(
nodes
(
node_file
[
i
],
node_file
[
i
+
1
],
node_file
[
i
+
2
]))
#prep edges
with
open
(
'
./test_files/kanter.txt
'
,
'
r
'
)
as
file
:
edge_file
=
file
.
read
()
...
...
@@ -45,7 +54,7 @@ for i in range(0, len(edge_file), 5):
#franode tilnode kjøretid lengde fartsgrense
edge_arr
.
append
(
edges
(
edge_file
[
i
],
edge_file
[
i
+
1
],
edge_file
[
i
+
2
],
edge_file
[
i
+
3
],
edge_file
[
i
+
4
]))
#prep intresting
with
open
(
'
./test_files/interessepkt.txt
'
,
'
r
'
)
as
file
:
intresting_file
=
file
.
read
()
...
...
@@ -59,5 +68,43 @@ for i in range(len(intresting_file)):
tmp_values
=
intresting_file
[
i
].
split
()
intresting_arr
.
append
(
int_points
(
tmp_values
[
0
],
tmp_values
[
1
],
'
'
.
join
(
tmp_values
[
2
:])))
res_arr
=
[]
def
init_table
():
for
i
in
range
(
len
(
node_file
)):
res_arr
.
append
(
results
(
i
,
inf
,
None
))
queue
=
[]
def
dijkstras
(
fra
,
til
):
if
fra
==
til
:
print
(
'
were here
'
)
for
i
in
edge_arr
:
if
fra
==
i
.
fra
:
a
=
[
a
for
a
in
queue
if
a
.
visited
==
None
and
a
.
node
==
i
.
til
]
if
a
:
queue
.
append
(
i
.
til
)
def
init_things
():
if
len
(
sys
.
argv
)
>
1
:
if
sys
.
argv
[
1
]
==
'
-d
'
:
#node_id
fra
=
0
til
=
1
init_table
()
dijkstras
(
fra
,
til
)
elif
sys
.
argv
[
1
]
==
'
-a
'
:
print
(
'
A* not yet implemented
'
)
else
:
print
(
'
Unknown argument
'
)
else
:
print
(
'
Missing argument
'
)
init_things
()
\ No newline at end of file
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