fix(csharp): Modify method name to PascalCase, simplify new expression (#840)

* Modify method name to PascalCase(array and linked list)

* Modify method name to PascalCase(backtracking)

* Modify method name to PascalCase(computational complexity)

* Modify method name to PascalCase(divide and conquer)

* Modify method name to PascalCase(dynamic programming)

* Modify method name to PascalCase(graph)

* Modify method name to PascalCase(greedy)

* Modify method name to PascalCase(hashing)

* Modify method name to PascalCase(heap)

* Modify method name to PascalCase(searching)

* Modify method name to PascalCase(sorting)

* Modify method name to PascalCase(stack and queue)

* Modify method name to PascalCase(tree)

* local check
This commit is contained in:
hpstory
2023-10-08 01:33:46 +08:00
committed by GitHub
parent 6f7e768cb7
commit f62256bee1
129 changed files with 1186 additions and 1192 deletions
+9 -9
View File
@@ -8,7 +8,7 @@ namespace hello_algo.chapter_graph;
public class graph_dfs {
/* 深度优先遍历 DFS 辅助函数 */
public void dfs(GraphAdjList graph, HashSet<Vertex> visited, List<Vertex> res, Vertex vet) {
public void Dfs(GraphAdjList graph, HashSet<Vertex> visited, List<Vertex> res, Vertex vet) {
res.Add(vet); // 记录访问顶点
visited.Add(vet); // 标记该顶点已被访问
// 遍历该顶点的所有邻接顶点
@@ -17,18 +17,18 @@ public class graph_dfs {
continue; // 跳过已被访问过的顶点
}
// 递归访问邻接顶点
dfs(graph, visited, res, adjVet);
Dfs(graph, visited, res, adjVet);
}
}
/* 深度优先遍历 DFS */
// 使用邻接表来表示图,以便获取指定顶点的所有邻接顶点
public List<Vertex> graphDFS(GraphAdjList graph, Vertex startVet) {
public List<Vertex> GraphDFS(GraphAdjList graph, Vertex startVet) {
// 顶点遍历序列
List<Vertex> res = new List<Vertex>();
List<Vertex> res = new();
// 哈希表,用于记录已被访问过的顶点
HashSet<Vertex> visited = new HashSet<Vertex>();
dfs(graph, visited, res, startVet);
HashSet<Vertex> visited = new();
Dfs(graph, visited, res, startVet);
return res;
}
@@ -42,12 +42,12 @@ public class graph_dfs {
new Vertex[2] { v[2], v[5] }, new Vertex[2] { v[4], v[5] }, new Vertex[2] { v[5], v[6] },
};
GraphAdjList graph = new GraphAdjList(edges);
GraphAdjList graph = new(edges);
Console.WriteLine("\n初始化后,图为");
graph.print();
graph.Print();
/* 深度优先遍历 DFS */
List<Vertex> res = graphDFS(graph, v[0]);
List<Vertex> res = GraphDFS(graph, v[0]);
Console.WriteLine("\n深度优先遍历(DFS)顶点序列为");
Console.WriteLine(string.Join(" ", Vertex.VetsToVals(res)));
}