Add lang blocks in graph_traversal.md

This commit is contained in:
krahets 2023-02-25 01:26:34 +08:00
parent 2d421de984
commit f894199d58
2 changed files with 24 additions and 10 deletions

View file

@ -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}
``` ```
深度优先遍历的算法流程如下图所示,其中 深度优先遍历的算法流程如下图所示,其中