package main import "fmt" type GraphNode struct { Name string Children []*GraphNode } func NewNode(name string) *GraphNode { return &GraphNode{ Name: name, } } func (n *GraphNode) AddChild(name string) { child := NewNode(name) n.Children = append(n.Children, child) } func (n *GraphNode) Print() { fmt.Println(n.Name) for _, child := range n.Children { fmt.Println(" -> ", child.Name) } }