MCPcopy Create free account
hub / github.com/acm-clan/algorithm-stone / construct

Method construct

animations/unionfind.py:105–130  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

103 self.show_message("每个节点初始状态都指向自己", 2)
104
105 def construct(self):
106 self.add_sound("bg002")
107 self.start_logo()
108 m = self.init_message("并查集")
109 leet = AlgoText("LeetCode 547.省份数量", color=GOLD_E).center().to_edge(UP).shift(UP*0.2)
110 self.play(ShowCreation(leet))
111
112 self.create_area()
113 # 从area创建网络
114 self.create_network()
115 # 从网络开始union
116 for i in range(self.data.shape[0]):
117 for j in range(i+1, self.data.shape[1]):
118 if self.data[i][j] == 1:
119 self.union(self.group, i, j)
120
121 # 遍历每个元素
122 c = 0
123 for i in range(self.data.shape[0]):
124 if self.group[i] == i:
125 c += 1
126
127 self.show_message("遍历,根节点指向自己的节点数量为%d"%(c))
128 self.show_message("完成并查集,谢谢观看!")
129
130 self.wait()

Callers

nothing calls this directly

Calls 7

create_areaMethod · 0.95
create_networkMethod · 0.95
unionMethod · 0.95
AlgoTextClass · 0.85
start_logoMethod · 0.80
init_messageMethod · 0.80
show_messageMethod · 0.45

Tested by

no test coverage detected