mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-08 20:16:30 +08:00
build
This commit is contained in:
@@ -15,19 +15,19 @@ comments: true
|
||||
- **删除顶点**:在邻接矩阵中删除一行一列。当删除首行首列时达到最差情况,需要将 $(n-1)^2$ 个元素“向左上移动”,从而使用 $O(n^2)$ 时间。
|
||||
- **初始化**:传入 $n$ 个顶点,初始化长度为 $n$ 的顶点列表 `vertices` ,使用 $O(n)$ 时间;初始化 $n \times n$ 大小的邻接矩阵 `adjMat` ,使用 $O(n^2)$ 时间。
|
||||
|
||||
=== "初始化邻接矩阵"
|
||||
=== "<1>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "添加边"
|
||||
=== "<2>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "删除边"
|
||||
=== "<3>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "添加顶点"
|
||||
=== "<4>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "删除顶点"
|
||||
=== "<5>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 9-7 邻接矩阵的初始化、增删边、增删顶点 </p>
|
||||
@@ -1221,19 +1221,19 @@ comments: true
|
||||
- **删除顶点**:需遍历整个邻接表,删除包含指定顶点的所有边,使用 $O(n + m)$ 时间。
|
||||
- **初始化**:在邻接表中创建 $n$ 个顶点和 $2m$ 条边,使用 $O(n + m)$ 时间。
|
||||
|
||||
=== "初始化邻接表"
|
||||
=== "<1>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "添加边"
|
||||
=== "<2>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "删除边"
|
||||
=== "<3>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "添加顶点"
|
||||
=== "<4>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
=== "删除顶点"
|
||||
=== "<5>"
|
||||
{ class="animation-figure" }
|
||||
|
||||
<p align="center"> 图 9-8 邻接表的初始化、增删边、增删顶点 </p>
|
||||
|
||||
Reference in New Issue
Block a user