Brian Buller
42d8211402
Since that's what they actually want, even though the exercise says it's a tree
24 lines
358 B
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)
|
|
}
|
|
}
|