exercism/go/pov/pov_helper.go
Brian Buller 42d8211402 Changing it into a graph
Since that's what they actually want, even though the exercise says it's
a tree
2017-08-24 11:16:04 -05:00

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