Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def cluster_2(ver, eds, num_of_clusters, parent, n):
- cnt = 1 # количество владельцев
- while(cnt < num_of_clusters):
- max_edg = 0
- for i in range(len(eds)):
- l = eds[i][0]
- a = eds[i][1]
- b = eds[i][2]
- if a != parent[b]:
- a, b = b, a
- if a == parent[b] and l >= max_edg:
- max_edg = l
- new_p = b
- parent[new_p] = new_p
- for i in range(len(eds)):
- l = eds[i][0]
- a = eds[i][1]
- b = eds[i][2]
- if a != parent[b]:
- a, b = b, a
- if a == parent[b] and l < eds[int(n * min(b, new_p) - min(b, new_p) * (min(b, new_p) + 1) / 2 + (max(b, new_p) - min(b, new_p)) - 1)][0]:
- parent[b] = new_p
- cnt += 1
- return parent
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement