Update the book based on the revised second edition (#1014)

* Revised the book

* Update the book with the second revised edition

* Revise base on the manuscript of the first edition
This commit is contained in:
Yudong Jin
2023-12-28 18:06:09 +08:00
committed by GitHub
parent 19dde675df
commit f68bbb0d59
261 changed files with 643 additions and 647 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ import (
. "github.com/krahets/hello-algo/pkg"
)
/* 广度优先遍历 BFS */
/* 广度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
func graphBFS(g *graphAdjList, startVet Vertex) []Vertex {
// 顶点遍历序列
+1 -1
View File
@@ -22,7 +22,7 @@ func TestGraphBFS(t *testing.T) {
fmt.Println("初始化后,图为:")
graph.print()
/* 广度优先遍历 BFS */
/* 广度优先遍历 */
res := graphBFS(graph, vets[0])
fmt.Println("广度优先遍历(BFS)顶点序列为:")
PrintSlice(VetsToVals(res))
+2 -2
View File
@@ -8,7 +8,7 @@ import (
. "github.com/krahets/hello-algo/pkg"
)
/* 深度优先遍历 DFS 辅助函数 */
/* 深度优先遍历辅助函数 */
func dfs(g *graphAdjList, visited map[Vertex]struct{}, res *[]Vertex, vet Vertex) {
// append 操作会返回新的的引用,必须让原引用重新赋值为新slice的引用
*res = append(*res, vet)
@@ -23,7 +23,7 @@ func dfs(g *graphAdjList, visited map[Vertex]struct{}, res *[]Vertex, vet Vertex
}
}
/* 深度优先遍历 DFS */
/* 深度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
func graphDFS(g *graphAdjList, startVet Vertex) []Vertex {
// 顶点遍历序列
+1 -1
View File
@@ -21,7 +21,7 @@ func TestGraphDFS(t *testing.T) {
fmt.Println("初始化后,图为:")
graph.print()
/* 深度优先遍历 DFS */
/* 深度优先遍历 */
res := graphDFS(graph, vets[0])
fmt.Println("深度优先遍历(DFS)顶点序列为:")
PrintSlice(VetsToVals(res))