Skip to content

Commit

Permalink
Rename variables inside the graphs.hasCycle function in order to impr…
Browse files Browse the repository at this point in the history
…ove readability
  • Loading branch information
mrekucci committed Dec 15, 2015
1 parent c8ac58d commit c669155
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions graphs/minconnected.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ type Vertex struct {
edges []*Vertex
}

func hasCycle(c, p *Vertex) bool {
if c.state == discovered { // Base case.
func hasCycle(curr, prev *Vertex) bool {
if curr.state == discovered { // Base case.
return true
}

c.state = discovered // In process.
for _, n := range c.edges {
if n != p && n.state != processed && hasCycle(n, c) {
curr.state = discovered // In process.
for _, next := range curr.edges {
if next != prev && next.state != processed && hasCycle(next, curr) {
return true
}
}
c.state = processed // Done.
curr.state = processed // Done.
return false
}

Expand Down

0 comments on commit c669155

Please sign in to comment.