Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박권수
/
Algorithm_HW5
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2020-11-01 18:27:29 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
110e4a395433d0908df4db0b485de74ba22af3c2
110e4a39
1 parent
c6bef59b
feature2.0.1 :define Dijkstra & edit Remark of Kruskal
q
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
HW5_박권수_2015104173.py
HW5_박권수_2015104173.py
View file @
110e4a3
...
...
@@ -25,6 +25,7 @@ def union(r1, r2) :
if
(
rank
[
r1
]
==
rank
[
r2
])
:
rank
[
r2
]
+=
1
#define Kruskal Algorithm : input = graph
def
Kruskal
(
graph
)
:
#n = 정점의 수 / m = 엣지의 수
n
=
len
(
graph
[
'vertices'
])
...
...
@@ -58,13 +59,14 @@ def Kruskal(graph) :
return
F
#Dijkstra Algorithm
#Dijkstra Algorithm : input = graph
def
dijkstra
(
w
)
:
n
=
len
(
w
)
#Kruskal Algorithm
#
practice about
Kruskal Algorithm
graph
=
{
'vertices'
:
[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
],
'edges'
:
set
([
...
...
@@ -85,4 +87,3 @@ print('Kruskal Algorithm : ', "\n", mst)
inf
=
1000
w
=
[[
0
,
7
,
4
,
6
,
1
],[
inf
,
0
,
inf
,
inf
,
inf
],
[
inf
,
2
,
0
,
5
,
inf
],
[
inf
,
3
,
inf
,
0
,
inf
],
[
inf
,
inf
,
inf
,
1
,
0
]]
n
=
len
(
w
)
...
...
Please
register
or
login
to post a comment