Changing it into a graph
Since that's what they actually want, even though the exercise says it's a tree
This commit is contained in:
BIN
go/pov/cmd/cmd
BIN
go/pov/cmd/cmd
Binary file not shown.
@@ -8,19 +8,13 @@ import (
|
||||
|
||||
func main() {
|
||||
g := pov.New()
|
||||
g.AddNode("parent")
|
||||
g.AddArc("parent", "x")
|
||||
g.AddArc("x", "sib-2")
|
||||
g.AddArc("x", "sib-3")
|
||||
g.AddArc("x", "sib-4")
|
||||
g.AddNode("sibling")
|
||||
g.AddNode("x")
|
||||
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")
|
||||
pov.PrintGraph(g)
|
||||
g.AddArc("parent", "x")
|
||||
fmt.Println("== Change Root to child-3 ==")
|
||||
n := g.ChangeRoot("parent", "child-3")
|
||||
pov.PrintGraph(n)
|
||||
g.Print("parent")
|
||||
n := g.ChangeRoot("parent", "x")
|
||||
fmt.Println(n.ArcList())
|
||||
g.Print("x")
|
||||
}
|
||||
|
Reference in New Issue
Block a user