exercism/go/pov/pov_helper.go

24 lines
358 B
Go
Raw Normal View History

2017-08-15 22:06:46 +00:00
package pov
import (
"fmt"
"strings"
)
func (g *Graph) Print(root string) {
r := g.getNode(root)
if r != nil {
r.Print(0)
} else {
fmt.Println("Couldn't find root node:", root)
2017-08-15 22:06:46 +00:00
}
}
func (n *Node) Print(ind int) {
pad := strings.Repeat(" ", ind)
fmt.Println(pad + n.label)
for i := range n.connections {
n.connections[i].Print(ind + 1)
2017-08-15 22:06:46 +00:00
}
}