mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-13 07:46:06 +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 @@ Given an undirected graph with $n$ vertices, the various operations are implemen
|
||||
- **Removing a vertex**: Delete a row and a column in the adjacency matrix. The worst case occurs when removing the first row and column, requiring $(n-1)^2$ elements to be "moved up and to the left", thus using $O(n^2)$ time.
|
||||
- **Initialization**: Pass in $n$ vertices, initialize a vertex list `vertices` of length $n$, using $O(n)$ time; initialize an adjacency matrix `adjMat` of size $n \times n$, using $O(n^2)$ time.
|
||||
|
||||
=== "Initialize adjacency matrix"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "Add an edge"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "Remove an edge"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
=== "Add a vertex"
|
||||
=== "<4>"
|
||||

|
||||
|
||||
=== "Remove a vertex"
|
||||
=== "<5>"
|
||||

|
||||
|
||||
The following is the implementation code for graphs represented using an adjacency matrix:
|
||||
@@ -42,19 +42,19 @@ Given an undirected graph with a total of $n$ vertices and $m$ edges, the variou
|
||||
- **Removing a vertex**: Traverse the entire adjacency list and remove all edges containing the specified vertex, using $O(n + m)$ time.
|
||||
- **Initialization**: Create $n$ vertices and $2m$ edges in the adjacency list, using $O(n + m)$ time.
|
||||
|
||||
=== "Initialize adjacency list"
|
||||
=== "<1>"
|
||||

|
||||
|
||||
=== "Add an edge"
|
||||
=== "<2>"
|
||||

|
||||
|
||||
=== "Remove an edge"
|
||||
=== "<3>"
|
||||

|
||||
|
||||
=== "Add a vertex"
|
||||
=== "<4>"
|
||||

|
||||
|
||||
=== "Remove a vertex"
|
||||
=== "<5>"
|
||||

|
||||
|
||||
The following is the adjacency list code implementation. Compared to the figure above, the actual code has the following differences.
|
||||
|
||||
Reference in New Issue
Block a user