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

View File

@ -7,7 +7,7 @@
const { GraphAdjList } = require('./graph_adjacency_list');
const { Vertex } = require('../modules/Vertex');
/* 广度优先遍历 BFS */
/* 广度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
function graphBFS(graph, startVet) {
// 顶点遍历序列
@ -55,7 +55,7 @@ const graph = new GraphAdjList(edges);
console.log('\n初始化后图为');
graph.print();
/* 广度优先遍历 BFS */
/* 广度优先遍历 */
const res = graphBFS(graph, v[0]);
console.log('\n广度优先遍历BFS顶点序列为');
console.log(Vertex.vetsToVals(res));

View File

@ -7,7 +7,7 @@
const { Vertex } = require('../modules/Vertex');
const { GraphAdjList } = require('./graph_adjacency_list');
/* 深度优先遍历 DFS */
/* 深度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
function dfs(graph, visited, res, vet) {
res.push(vet); // 记录访问顶点
@ -22,7 +22,7 @@ function dfs(graph, visited, res, vet) {
}
}
/* 深度优先遍历 DFS */
/* 深度优先遍历 */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
function graphDFS(graph, startVet) {
// 顶点遍历序列
@ -48,7 +48,7 @@ const graph = new GraphAdjList(edges);
console.log('\n初始化后图为');
graph.print();
/* 深度优先遍历 DFS */
/* 深度优先遍历 */
const res = graphDFS(graph, v[0]);
console.log('\n深度优先遍历DFS顶点序列为');
console.log(Vertex.vetsToVals(res));