2017-08-15 22:06:46 +00:00
|
|
|
package pov
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2017-08-24 16:16:04 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-24 16:16:04 +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
|
|
|
}
|
|
|
|
}
|