From b973c86ee426949f3e0161a6272bcd9811d7064b Mon Sep 17 00:00:00 2001 From: krahets Date: Thu, 9 Feb 2023 23:12:28 +0800 Subject: [PATCH] Fix the initial edges in graph_adjacency_matrix --- codes/go/chapter_graph/graph_adjacency_matrix_test.go | 2 +- codes/java/chapter_graph/graph_adjacency_matrix.java | 2 +- codes/swift/chapter_graph/graph_adjacency_matrix.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codes/go/chapter_graph/graph_adjacency_matrix_test.go b/codes/go/chapter_graph/graph_adjacency_matrix_test.go index 1a4755791..90056ff26 100644 --- a/codes/go/chapter_graph/graph_adjacency_matrix_test.go +++ b/codes/go/chapter_graph/graph_adjacency_matrix_test.go @@ -13,7 +13,7 @@ func TestGraphAdjMat(t *testing.T) { /* 初始化无向图 */ // 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 vertices := []int{1, 3, 2, 5, 4} - edges := [][]int{{0, 1}, {0, 2}, {1, 2}, {2, 3}, {0, 3}, {2, 4}, {3, 4}} + edges := [][]int{{0, 1}, {1, 2}, {2, 3}, {0, 3}, {2, 4}, {3, 4}} graph := newGraphAdjMat(vertices, edges) fmt.Println("初始化后,图为:") graph.print() diff --git a/codes/java/chapter_graph/graph_adjacency_matrix.java b/codes/java/chapter_graph/graph_adjacency_matrix.java index 1fd83ff97..7796c1ac6 100644 --- a/codes/java/chapter_graph/graph_adjacency_matrix.java +++ b/codes/java/chapter_graph/graph_adjacency_matrix.java @@ -100,7 +100,7 @@ public class graph_adjacency_matrix { /* 初始化无向图 */ // 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 int[] vertices = { 1, 3, 2, 5, 4 }; - int[][] edges = { { 0, 1 }, { 0, 2 }, { 1, 2 }, { 2, 3 }, { 0, 3 }, { 2, 4 }, { 3, 4 } }; + int[][] edges = { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 0, 3 }, { 2, 4 }, { 3, 4 } }; GraphAdjMat graph = new GraphAdjMat(vertices, edges); System.out.println("\n初始化后,图为"); graph.print(); diff --git a/codes/swift/chapter_graph/graph_adjacency_matrix.swift b/codes/swift/chapter_graph/graph_adjacency_matrix.swift index 34321fd34..46eac587c 100644 --- a/codes/swift/chapter_graph/graph_adjacency_matrix.swift +++ b/codes/swift/chapter_graph/graph_adjacency_matrix.swift @@ -99,7 +99,7 @@ enum GraphAdjacencyMatrix { /* 初始化无向图 */ // 请注意,edges 元素代表顶点索引,即对应 vertices 元素索引 let vertices = [1, 3, 2, 5, 4] - let edges = [[0, 1], [0, 2], [1, 2], [2, 3], [0, 3], [2, 4], [3, 4]] + let edges = [[0, 1], [1, 2], [2, 3], [0, 3], [2, 4], [3, 4]] let graph = GraphAdjMat(vertices: vertices, edges: edges) print("\n初始化后,图为") graph.print()