@@ -2,8 +2,8 @@ package adjacency_list
2
2
3
3
func (g * Graph ) Adjacent (x , y int ) bool {
4
4
if nodeX , ok := g .adjList [x ]; ok {
5
- for _ , v := range nodeX {
6
- if v == y {
5
+ for _ , v := range nodeX {
6
+ if v == y {
7
7
return true
8
8
}
9
9
}
@@ -18,7 +18,7 @@ func (g *Graph) Neighbors(x int) []int {
18
18
return []int {}
19
19
}
20
20
21
- func (g * Graph ) AddVertex (x int ) {
21
+ func (g * Graph ) AddVertex (x int ) {
22
22
if _ , ok := g .adjList [x ]; ! ok {
23
23
g .adjList [x ] = make ([]int , 0 , 4 )
24
24
g .values [x ] = nil
@@ -32,7 +32,7 @@ func (g *Graph) RemoveVertex(x int) {
32
32
}
33
33
}
34
34
35
- func (g * Graph ) AddEdge (x , y int ) {
35
+ func (g * Graph ) AddEdge (x , y int ) {
36
36
if g .Adjacent (x , y ) {
37
37
return
38
38
}
@@ -48,7 +48,7 @@ func (g *Graph) RemoveEdge(x, y int) {
48
48
// Move last element to the position of element, that would be deleted
49
49
// And truncates slice (remove last element)
50
50
nodeX [idx ] = nodeX [len (nodeX )- 1 ]
51
- g .adjList [x ] = nodeX [0 : len (nodeX )- 1 ]
51
+ g .adjList [x ] = nodeX [0 : len (nodeX )- 1 ]
52
52
}
53
53
}
54
54
}
@@ -66,4 +66,3 @@ func (g *Graph) SetVertexValue(x int, v interface{}) (ok bool) {
66
66
g .values [x ] = v
67
67
return true
68
68
}
69
-
0 commit comments