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:
2017-08-24 11:16:04 -05:00
parent dc34a45b94
commit 42d8211402
6 changed files with 325 additions and 120 deletions

Binary file not shown.

View File

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