Skip to content

Commit 3208c2b

Browse files
committed
init G
1 parent 13fb248 commit 3208c2b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Dijkstra.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,64 @@ import (
44
"fmt"
55
)
66

7+
const MAX_SIZE int = 5
8+
const MAX_VALUE int = 0
9+
710
func main() {
811
fmt.Println("Dijkstra")
12+
var gg Graph
13+
var vexs = []string{"B", "A", "C", "D", "E"}
14+
gg.vexnum = 5
15+
gg.vexs = vexs
16+
initGG(&gg, vexs)
17+
PrintG(gg, 5)
18+
}
19+
20+
type Graph struct {
21+
vexs []string //定点集合
22+
vexnum int //定点数量
23+
edgnum int //边数量
24+
matrix [MAX_SIZE][MAX_SIZE]int //邻接矩阵
25+
}
26+
27+
type Edge struct {
28+
start string
29+
end string
30+
weight int
931
}
1032

1133
func Dijkstra() {
1234

1335
}
36+
37+
func initGG(gg *Graph, vexs []string) {
38+
for i := 0; i < len(vexs); i++ {
39+
for j := 0; j < len(vexs); j++ {
40+
gg.matrix[i][j] = MAX_VALUE
41+
}
42+
}
43+
gg.matrix[0][1] = 5
44+
gg.matrix[0][2] = 3
45+
46+
gg.matrix[1][0] = 5
47+
gg.matrix[1][3] = 7
48+
gg.matrix[1][4] = 4
49+
50+
gg.matrix[2][0] = 3
51+
gg.matrix[2][3] = 6
52+
53+
gg.matrix[3][1] = 7
54+
gg.matrix[3][2] = 6
55+
gg.matrix[3][4] = 1
56+
57+
gg.matrix[4][1] = 4
58+
gg.matrix[4][3] = 1
59+
60+
gg.edgnum = 12 / 2
61+
}
62+
63+
func PrintG(gg Graph, l int) {
64+
for i := 0; i < l; i++ {
65+
fmt.Println(gg.matrix[i])
66+
}
67+
}

quicksort.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"fmt"
55
)
66

7+
//为了看上去 好一些
8+
const MAX_VALUE int = 9
9+
710
func main() {
811
var arr = []int{6, 5, 5, 3, 1, 8, 7, 2, 4, 9}
912
start := 0

0 commit comments

Comments
 (0)