exercism/go/pov/pov_helper.go

24 lines
358 B
Go

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)
}
}
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)
}
}