mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-12 03:40:58 +00:00
Add animation player (#1877)
* Add auto slide controller. * Fix the animation blocks. * renamed as animation_player * Bug fixes * Refine animation player controls
This commit is contained in:
@@ -11,19 +11,19 @@
|
||||
- **刪除頂點**:在鄰接矩陣中刪除一行一列。當刪除首行首列時達到最差情況,需要將 $(n-1)^2$ 個元素“向左上移動”,從而使用 $O(n^2)$ 時間。
|
||||
- **初始化**:傳入 $n$ 個頂點,初始化長度為 $n$ 的頂點串列 `vertices` ,使用 $O(n)$ 時間;初始化 $n \times n$ 大小的鄰接矩陣 `adjMat` ,使用 $O(n^2)$ 時間。
|
||||
|
||||
=== "初始化鄰接矩陣"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "新增邊"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "刪除邊"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
=== "新增頂點"
|
||||
=== "<4>"
|
||||

|
||||
|
||||
=== "刪除頂點"
|
||||
=== "<5>"
|
||||

|
||||
|
||||
以下是基於鄰接矩陣表示圖的實現程式碼:
|
||||
@@ -42,19 +42,19 @@
|
||||
- **刪除頂點**:需走訪整個鄰接表,刪除包含指定頂點的所有邊,使用 $O(n + m)$ 時間。
|
||||
- **初始化**:在鄰接表中建立 $n$ 個頂點和 $2m$ 條邊,使用 $O(n + m)$ 時間。
|
||||
|
||||
=== "初始化鄰接表"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "新增邊"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "刪除邊"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
=== "新增頂點"
|
||||
=== "<4>"
|
||||

|
||||
|
||||
=== "刪除頂點"
|
||||
=== "<5>"
|
||||

|
||||
|
||||
以下是鄰接表的程式碼實現。對比上圖,實際程式碼有以下不同。
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user