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