Skip to content

Commit 04854e9

Browse files
author
Ubuntu
committed
remove adjacencyList in graph; all graph use adjacency matrix which implemented by linked map
1 parent 1cde356 commit 04854e9

11 files changed

+20
-334
lines changed

graph/bfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func checkBFSGraphOutOfOrder(t *testing.T, g graph, gGolden graph) {
106106
}
107107

108108
func TestBFS(t *testing.T) {
109-
g := newAdjacencyList()
109+
g := newAdjacencyMatrix()
110110
bfsSetupGraph(g)
111111
bfsGraph := bfs(g, "s")
112112
expBfsGraph := bfsGolden(g)

graph/bioConnectedComp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func checkBCCGraphOutOfOrder(t *testing.T, g graph, gGloden graph) {
162162
}
163163

164164
func TestVertexBCC(t *testing.T) {
165-
g := newAdjacencyList()
165+
g := newAdjacencyMatrix()
166166
bccSetupGraph(g)
167167
cuts, comps := vertexBCC(g)
168168
cutsExp, compsExp := vertexBCCGolden(g)
@@ -173,7 +173,7 @@ func TestVertexBCC(t *testing.T) {
173173
}
174174

175175
func TestEdgeBCC(t *testing.T) {
176-
g := newAdjacencyList()
176+
g := newAdjacencyMatrix()
177177
bccSetupGraph(g)
178178
bridges, comps := edgeBCC(g)
179179
bridgesExp, compsExp := edgeBCCGolden(g)

graph/dfs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func dfsGolden(g graph) *dfsForest {
8989
}
9090

9191
func TestDFS(t *testing.T) {
92-
g := newAdjacencyList()
92+
g := newAdjacencyMatrix()
9393
dfsSetupGraph(g)
9494
dfsGraph := dfs(g, func(vertices []interface{}) {
9595
sort.Slice(vertices, func(i, j int) bool {

graph/eulerCircuit_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func udEulerCircuitSetup(g graph) {
2828
}
2929

3030
func TestDiEulerCircuitOK(t *testing.T) {
31-
g := newAdjacencyList()
31+
g := newAdjacencyMatrix()
3232
diEulerCircuitSetup(g)
3333
for i := 0; i < 3; i++ {
3434
path := eulerCircuit(g)
@@ -41,7 +41,7 @@ func TestDiEulerCircuitOK(t *testing.T) {
4141
}
4242

4343
func TestDiEulerCircuitWithSingleVertex(t *testing.T) {
44-
g := newAdjacencyList()
44+
g := newAdjacencyMatrix()
4545
diEulerCircuitSetup(g)
4646
g.AddVertex(6)
4747
path := eulerCircuit(g)
@@ -52,7 +52,7 @@ func TestDiEulerCircuitWithSingleVertex(t *testing.T) {
5252
}
5353

5454
func TestDiEulerCircuitWithSingleVertexLoop(t *testing.T) {
55-
g := newAdjacencyList()
55+
g := newAdjacencyMatrix()
5656
diEulerCircuitSetup(g)
5757
g.AddEdgeBi(edge{6, 6})
5858
path := eulerCircuit(g)
@@ -63,7 +63,7 @@ func TestDiEulerCircuitWithSingleVertexLoop(t *testing.T) {
6363
}
6464

6565
func TestDiEulerCircuitWithNonCircuit(t *testing.T) {
66-
g := newAdjacencyList()
66+
g := newAdjacencyMatrix()
6767
diEulerCircuitSetup(g)
6868
g.AddEdge(edge{6, 1})
6969
path := eulerCircuit(g)
@@ -72,7 +72,7 @@ func TestDiEulerCircuitWithNonCircuit(t *testing.T) {
7272
t.Fail()
7373
}
7474

75-
g = newAdjacencyList()
75+
g = newAdjacencyMatrix()
7676
diEulerCircuitSetup(g)
7777
g.AddEdge(edge{1, 6})
7878
path = eulerCircuit(g)
@@ -83,7 +83,7 @@ func TestDiEulerCircuitWithNonCircuit(t *testing.T) {
8383
}
8484

8585
func TestUdEulerCircuitOK(t *testing.T) {
86-
g := newAdjacencyList()
86+
g := newAdjacencyMatrix()
8787
udEulerCircuitSetup(g)
8888
path := eulerCircuit(g)
8989
pathExp := eulerCircuitGolden()
@@ -94,7 +94,7 @@ func TestUdEulerCircuitOK(t *testing.T) {
9494
}
9595

9696
func TestUdEulerCircuitWithSingleVertex(t *testing.T) {
97-
g := newAdjacencyList()
97+
g := newAdjacencyMatrix()
9898
udEulerCircuitSetup(g)
9999
g.AddVertex(6)
100100
path := eulerCircuit(g)
@@ -105,7 +105,7 @@ func TestUdEulerCircuitWithSingleVertex(t *testing.T) {
105105
}
106106

107107
func TestUdEulerCircuitWithNonCircuit(t *testing.T) {
108-
g := newAdjacencyList()
108+
g := newAdjacencyMatrix()
109109
udEulerCircuitSetup(g)
110110
g.AddEdgeBi(edge{1, 6})
111111
path := eulerCircuit(g)

0 commit comments

Comments
 (0)