From e8f311e900bcf56257fbb86c9a93d8af9b6b2caf Mon Sep 17 00:00:00 2001 From: zhuoqinyue <64182179+zhuoqinyue@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:15:46 -0600 Subject: [PATCH] update: Use function declarations instead of function expressions. (#385) Co-authored-by: steak-zhuo --- codes/javascript/chapter_graph/graph_bfs.js | 2 +- codes/javascript/chapter_graph/graph_dfs.js | 4 ++-- codes/typescript/chapter_graph/graph_bfs.ts | 2 +- codes/typescript/chapter_graph/graph_dfs.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codes/javascript/chapter_graph/graph_bfs.js b/codes/javascript/chapter_graph/graph_bfs.js index 092a5f8cf..695bc42dc 100644 --- a/codes/javascript/chapter_graph/graph_bfs.js +++ b/codes/javascript/chapter_graph/graph_bfs.js @@ -11,7 +11,7 @@ const { Vertex } = require('../include/Vertex'); /* 广度优先遍历 BFS */ // 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点 -const graphBfs = (graph, startVet) => { +function graphBfs(graph, startVet) { // 顶点遍历序列 const res = []; // 哈希表,用于记录已被访问过的顶点 diff --git a/codes/javascript/chapter_graph/graph_dfs.js b/codes/javascript/chapter_graph/graph_dfs.js index 30439902e..e4abaafa6 100644 --- a/codes/javascript/chapter_graph/graph_dfs.js +++ b/codes/javascript/chapter_graph/graph_dfs.js @@ -10,7 +10,7 @@ const { GraphAdjList } = require('./graph_adjacency_list'); /* 深度优先遍历 DFS */ // 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点 -const dfs = (graph, visited, res, vet) => { +function dfs(graph, visited, res, vet) { res.push(vet); // 记录访问顶点 visited.add(vet); // 标记该顶点已被访问 // 遍历该顶点的所有邻接顶点 @@ -25,7 +25,7 @@ const dfs = (graph, visited, res, vet) => { /* 深度优先遍历 DFS */ // 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点 -const graphDFS = (graph, startVet) => { +function graphDFS(graph, startVet) { // 顶点遍历序列 const res = []; // 哈希表,用于记录已被访问过的顶点 diff --git a/codes/typescript/chapter_graph/graph_bfs.ts b/codes/typescript/chapter_graph/graph_bfs.ts index 48e2a615b..4f1adc220 100644 --- a/codes/typescript/chapter_graph/graph_bfs.ts +++ b/codes/typescript/chapter_graph/graph_bfs.ts @@ -10,7 +10,7 @@ import { Vertex } from '../module/Vertex'; /* 广度优先遍历 BFS */ // 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点 -const graphBfs = (graph: GraphAdjList, startVet: Vertex): Vertex[] => { +function graphBfs(graph: GraphAdjList, startVet: Vertex): Vertex[] { // 顶点遍历序列 const res: Vertex[] = []; // 哈希表,用于记录已被访问过的顶点 diff --git a/codes/typescript/chapter_graph/graph_dfs.ts b/codes/typescript/chapter_graph/graph_dfs.ts index 9a4786f5e..4f23bff23 100644 --- a/codes/typescript/chapter_graph/graph_dfs.ts +++ b/codes/typescript/chapter_graph/graph_dfs.ts @@ -9,7 +9,7 @@ import { Vertex } from '../module/Vertex'; import { GraphAdjList } from './graph_adjacency_list'; /* 深度优先遍历 DFS 辅助函数 */ -const dfs = (graph: GraphAdjList, visited: Set, res: Vertex[], vet: Vertex): void => { +function dfs(graph: GraphAdjList, visited: Set, res: Vertex[], vet: Vertex): void { res.push(vet); // 记录访问顶点 visited.add(vet); // 标记该顶点已被访问 // 遍历该顶点的所有邻接顶点 @@ -24,7 +24,7 @@ const dfs = (graph: GraphAdjList, visited: Set, res: Vertex[], vet: Vert /* 深度优先遍历 DFS */ // 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点 -const graphDFS = (graph: GraphAdjList, startVet: Vertex): Vertex[] => { +function graphDFS(graph: GraphAdjList, startVet: Vertex): Vertex[] { // 顶点遍历序列 const res: Vertex[] = []; // 哈希表,用于记录已被访问过的顶点