Skip to content

Commit 5ff916a

Browse files
committed
removed necessary comments
1 parent c5bb51e commit 5ff916a

File tree

2 files changed

+0
-9
lines changed

2 files changed

+0
-9
lines changed

searches/breadth_first_search.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import "fmt"
44

5-
// getIdx return target node index
65
func getIdx(target int, nodes []int) int {
76
for i := 0; i < len(nodes); i++ {
87
if nodes[i] == target {
@@ -21,7 +20,6 @@ func notExist(target int, slice []int) bool {
2120
return true
2221
}
2322

24-
// bfs return whether start reach end or not.
2523
func bfs(start, end int, nodes []int, edges [][]bool) bool {
2624
var route []int
2725
var queue []int
@@ -30,7 +28,6 @@ func bfs(start, end int, nodes []int, edges [][]bool) bool {
3028
for len(queue) > 0 {
3129
now := queue[0]
3230
route = append(route, nodes[now])
33-
// update queue
3431
if len(queue) > 1 {
3532
queue = queue[1:]
3633
} else {
@@ -51,7 +48,6 @@ func bfs(start, end int, nodes []int, edges [][]bool) bool {
5148
}
5249

5350
func main() {
54-
// show graph as node 1-demensional matrix, edge 2-demensional matrix
5551
nodes := []int{
5652
1, 2, 3, 4, 5, 6,
5753
}

searches/depth_first_search.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import "fmt"
44

5-
// getIdx return target node index
65
func getIdx(target int, nodes []int) int {
76
for i := 0; i < len(nodes); i++ {
87
if nodes[i] == target {
@@ -21,7 +20,6 @@ func notExist(target int, slice []int) bool {
2120
return true
2221
}
2322

24-
// dfs return route, whether reach end or not
2523
func dfs(start, end int, nodes []int, edges [][]bool) ([]int, bool) {
2624
var route []int
2725
var stack []int
@@ -30,14 +28,12 @@ func dfs(start, end int, nodes []int, edges [][]bool) ([]int, bool) {
3028
for len(stack) > 0 {
3129
now := stack[len(stack)-1]
3230
route = append(route, nodes[now])
33-
// update stack
3431
if len(stack) > 1 {
3532
stack = stack[:len(stack)-1]
3633
} else {
3734
stack = stack[:len(stack)-1]
3835
}
3936
for i := 0; i < len(edges[now]); i++ {
40-
// exist edge
4137
if edges[now][i] && notExist(i, stack) {
4238
stack = append(stack, i)
4339
}
@@ -52,7 +48,6 @@ func dfs(start, end int, nodes []int, edges [][]bool) ([]int, bool) {
5248
}
5349

5450
func main() {
55-
// show graph as node 1-demensional matrix, edge 2-demensional matrix
5651
nodes := []int{
5752
1, 2, 3, 4, 5, 6,
5853
}

0 commit comments

Comments
 (0)