mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 14:18:20 +08:00 
			
		
		
		
	Add lang blocks in graph_traversal.md
This commit is contained in:
		@ -37,7 +37,7 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "C++"
 | 
			
		||||
 | 
			
		||||
    ```cpp title="graph_bfs.cpp"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "Python"
 | 
			
		||||
@ -49,31 +49,31 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "Go"
 | 
			
		||||
 | 
			
		||||
    ```go title="graph_bfs.go"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "JavaScript"
 | 
			
		||||
 | 
			
		||||
    ```javascript title="graph_bfs.js"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "TypeScript"
 | 
			
		||||
 | 
			
		||||
    ```typescript title="graph_bfs.ts"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "C"
 | 
			
		||||
 | 
			
		||||
    ```c title="graph_bfs.c"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "C#"
 | 
			
		||||
 | 
			
		||||
    ```csharp title="graph_bfs.cs"
 | 
			
		||||
 | 
			
		||||
    [class]{graph_bfs}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "Swift"
 | 
			
		||||
@ -85,7 +85,7 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "Zig"
 | 
			
		||||
 | 
			
		||||
    ```zig title="graph_bfs.zig"
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphBFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
代码相对抽象,建议对照以下动画图示来加深理解。
 | 
			
		||||
@ -154,7 +154,9 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "C++"
 | 
			
		||||
 | 
			
		||||
    ```cpp title="graph_dfs.cpp"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "Python"
 | 
			
		||||
@ -168,31 +170,41 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "Go"
 | 
			
		||||
 | 
			
		||||
    ```go title="graph_dfs.go"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "JavaScript"
 | 
			
		||||
 | 
			
		||||
    ```javascript title="graph_dfs.js"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "TypeScript"
 | 
			
		||||
 | 
			
		||||
    ```typescript title="graph_dfs.ts"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "C"
 | 
			
		||||
 | 
			
		||||
    ```c title="graph_dfs.c"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "C#"
 | 
			
		||||
 | 
			
		||||
    ```csharp title="graph_dfs.cs"
 | 
			
		||||
    [class]{graph_dfs}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{graph_dfs}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
=== "Swift"
 | 
			
		||||
@ -206,7 +218,9 @@ BFS 常借助「队列」来实现。队列具有“先入先出”的性质,
 | 
			
		||||
=== "Zig"
 | 
			
		||||
 | 
			
		||||
    ```zig title="graph_dfs.zig"
 | 
			
		||||
    [class]{}-[func]{dfs}
 | 
			
		||||
 | 
			
		||||
    [class]{}-[func]{graphDFS}
 | 
			
		||||
    ```
 | 
			
		||||
 | 
			
		||||
深度优先遍历的算法流程如下图所示,其中
 | 
			
		||||
 | 
			
		||||
@ -129,7 +129,7 @@ nav:
 | 
			
		||||
    - 0.2.   如何使用本书: chapter_preface/suggestions.md
 | 
			
		||||
    - 0.3.   编程环境安装: chapter_preface/installation.md
 | 
			
		||||
    - 0.4.   一起参与创作: chapter_preface/contribution.md
 | 
			
		||||
  - 1.     引言: 
 | 
			
		||||
  - 1.     引言:
 | 
			
		||||
    - 1.1.   算法无处不在: chapter_introduction/algorithms_are_everywhere.md
 | 
			
		||||
    - 1.2.   算法是什么: chapter_introduction/what_is_dsa.md
 | 
			
		||||
  - 2.     计算复杂度:
 | 
			
		||||
@ -138,11 +138,11 @@ nav:
 | 
			
		||||
    - 2.3.   空间复杂度: chapter_computational_complexity/space_complexity.md
 | 
			
		||||
    - 2.4.   权衡时间与空间: chapter_computational_complexity/space_time_tradeoff.md
 | 
			
		||||
    - 2.5.   小结: chapter_computational_complexity/summary.md
 | 
			
		||||
  - 3.     数据结构简介: 
 | 
			
		||||
  - 3.     数据结构简介:
 | 
			
		||||
    - 3.1.   数据与内存: chapter_data_structure/data_and_memory.md
 | 
			
		||||
    - 3.2.   数据结构分类: chapter_data_structure/classification_of_data_structure.md
 | 
			
		||||
    - 3.3.   小结: chapter_data_structure/summary.md
 | 
			
		||||
  - 4.     数组与链表: 
 | 
			
		||||
  - 4.     数组与链表:
 | 
			
		||||
    - 4.1.   数组(Array): chapter_array_and_linkedlist/array.md
 | 
			
		||||
    - 4.2.   链表(LinkedList): chapter_array_and_linkedlist/linked_list.md
 | 
			
		||||
    - 4.3.   列表(List): chapter_array_and_linkedlist/list.md
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user