day 8p2 done! + some cleaning to p1
This commit is contained in:
10
8/ex1.py
10
8/ex1.py
@@ -47,15 +47,15 @@ if __name__ == "__main__":
|
||||
graph, num_vertices = build_graph()
|
||||
graph.sort(key=lambda x: x[2])
|
||||
dsu = DSU(num_vertices)
|
||||
conns = 0
|
||||
attempted = 0
|
||||
for u, v, w in graph:
|
||||
attempted += 1
|
||||
if dsu.union(u, v):
|
||||
if attempted >= 1000:
|
||||
break
|
||||
dsu.union(u, v)
|
||||
if attempted >= DESIRED_CONNS:
|
||||
break
|
||||
|
||||
|
||||
|
||||
print(f"Attempted edges: {attempted}, Connections made: {conns}")
|
||||
component_sizes = {}
|
||||
for i in range(num_vertices):
|
||||
root = dsu.find(i)
|
||||
|
||||
Reference in New Issue
Block a user