-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkruskal.py
47 lines (37 loc) · 1.1 KB
/
kruskal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Aristas:
def __init__(self, i=0, j=0):
self.i = i
self.j = j
def partition(number_of_vertices):
#TODO implement
pass
def sort(candidates_set):
#TODO implement
pass
def select(candidates_set):
#TODO implement
pass
def search(p, number_of_vertices, vertex):
#TODO implement
pass
def fusion(candidates_selected):
#TODO implement
pass
def objetivo(candidates_selected):
#TODO implement
pass
def Kruskal(vertices,aristas):
candidates_set = aristas
candidates_selected=[]
number_of_vertices = vertices.count()
p = partition(number_of_vertices)
sort(candidates_selected)
while candidates_selected.count() != number_of_vertices - 1:
arista_seleccionada = select(candidates_set)
candidates_set.remove(arista_seleccionada)
p1 = search(p,number_of_vertices, arista_seleccionada.i)
p2 = search(p , number_of_vertices, arista_seleccionada.j)
if p1 != p2:
fusion(p,number_of_vertices,p1,p2)
candidates_selected.append(arista_seleccionada)
return candidates_selected