mirror of
https://github.com/krahets/hello-algo.git
synced 2025-12-16 03:59:18 +08:00
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:
@@ -9,7 +9,7 @@ import 'dart:collection';
|
||||
import '../utils/vertex.dart';
|
||||
import 'graph_adjacency_list.dart';
|
||||
|
||||
/* 广度优先遍历 BFS */
|
||||
/* 广度优先遍历 */
|
||||
List<Vertex> graphBFS(GraphAdjList graph, Vertex startVet) {
|
||||
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
|
||||
// 顶点遍历序列
|
||||
@@ -59,7 +59,7 @@ void main() {
|
||||
print("\n初始化后,图为");
|
||||
graph.printAdjList();
|
||||
|
||||
/* 广度优先遍历 BFS */
|
||||
/* 广度优先遍历 */
|
||||
List<Vertex> res = graphBFS(graph, v[0]);
|
||||
print("\n广度优先遍历(BFS)顶点序列为");
|
||||
print(Vertex.vetsToVals(res));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import '../utils/vertex.dart';
|
||||
import 'graph_adjacency_list.dart';
|
||||
|
||||
/* 深度优先遍历 DFS 辅助函数 */
|
||||
/* 深度优先遍历辅助函数 */
|
||||
void dfs(
|
||||
GraphAdjList graph,
|
||||
Set<Vertex> visited,
|
||||
@@ -26,7 +26,7 @@ void dfs(
|
||||
}
|
||||
}
|
||||
|
||||
/* 深度优先遍历 DFS */
|
||||
/* 深度优先遍历 */
|
||||
List<Vertex> graphDFS(GraphAdjList graph, Vertex startVet) {
|
||||
// 顶点遍历序列
|
||||
List<Vertex> res = [];
|
||||
@@ -52,7 +52,7 @@ void main() {
|
||||
print("\n初始化后,图为");
|
||||
graph.printAdjList();
|
||||
|
||||
/* 深度优先遍历 DFS */
|
||||
/* 深度优先遍历 */
|
||||
List<Vertex> res = graphDFS(graph, v[0]);
|
||||
print("\n深度优先遍历(DFS)顶点序列为");
|
||||
print(Vertex.vetsToVals(res));
|
||||
|
||||
Reference in New Issue
Block a user