exercism/go/pov/cmd/main.go

27 lines
528 B
Go
Raw Normal View History

2017-08-15 22:06:46 +00:00
package main
2017-08-17 18:12:16 +00:00
import (
"fmt"
pov ".."
)
2017-08-15 22:06:46 +00:00
func main() {
g := pov.New()
g.AddNode("parent")
g.AddArc("parent", "x")
2017-08-17 18:12:16 +00:00
g.AddArc("x", "sib-2")
g.AddArc("x", "sib-3")
g.AddArc("x", "sib-4")
g.AddArc("parent", "sibling")
g.AddArc("sibling", "child-1")
g.AddArc("sibling", "child-2")
g.AddArc("sibling", "child-3")
g.AddArc("child-3", "grandchild-1")
g.AddArc("grandchild-1", "greatgrandchild-1")
2017-08-15 22:06:46 +00:00
pov.PrintGraph(g)
2017-08-17 18:12:16 +00:00
fmt.Println("== Change Root to child-3 ==")
n := g.ChangeRoot("parent", "child-3")
pov.PrintGraph(n)
2017-08-15 22:06:46 +00:00
}