refactor: add/refactor method in include, simplified print code (#471)

This commit is contained in:
hpstory
2023-04-21 14:59:22 +08:00
committed by GitHub
parent 9c2e5e2831
commit 9eeefff447
24 changed files with 102 additions and 109 deletions

View File

@ -46,7 +46,7 @@ public class graph_bfs
public void Test()
{
/* 初始化无向图 */
Vertex[] v = Vertex.valsToVets(new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
Vertex[] v = Vertex.ValsToVets(new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
Vertex[][] edges = new Vertex[12][]
{
new Vertex[2] { v[0], v[1] }, new Vertex[2] { v[0], v[3] }, new Vertex[2] { v[1], v[2] },
@ -62,6 +62,6 @@ public class graph_bfs
/* 广度优先遍历 BFS */
List<Vertex> res = graphBFS(graph, v[0]);
Console.WriteLine("\n广度优先遍历BFS顶点序列为");
Console.WriteLine(string.Join(" ", Vertex.vetsToVals(res)));
Console.WriteLine(string.Join(" ", Vertex.VetsToVals(res)));
}
}