code: func (g *AcyclicGraph) Validate() error {
  	if _, err := g.Root(); err != nil {
  		return err
  	}
  
  	// Look for cycles of more than 1 component
  	var err error
  	cycles := g.Cycles()
  	if len(cycles) > 0 {
  		for _, cycle := range cycles {
  			cycleStr := make([]string, len(cycle))
  			for j, vertex := range cycle {
  				cycleStr[j] = VertexName(vertex)
  			}
  
  			err = multierror.Append(err, fmt.Errorf(
  				"Cycle: %s", strings.Join(cycleStr, ", ")))
  		}
  	}
  
  	// Look for cycles to self
  	for _, e := range g.Edges() {
  		if e.Source() == e.Target() {
  			err = multierror.Append(err, fmt.Errorf(
  				"Self reference: %s", VertexName(e.Source())))
  		}
  	}
  
  	return err
  }
docs: // Validate validates the DAG. A DAG is valid if it has a single root
  // with no cycles.