in graph/dag.go [167:192]
func (d *Dag) validateFromAndTo(from string, to string) (fromNode *Node, toNode *Node, err error) {
if from == "" {
return nil, nil, errors.New("from cannot be empty")
}
if to == "" {
return nil, nil, errors.New("to cannot be empty")
}
if from == to {
return nil, nil, errors.New("from and to cannot be the same")
}
d.mu.Lock()
defer d.mu.Unlock()
if from == rootNodeID {
fromNode = d.Root
} else {
var ok bool
if fromNode, ok = d.Nodes[from]; !ok {
return nil, nil, fmt.Errorf("%v does not exist as a vertex [from: %v, to: %v]", from, from, to)
}
}
toNode, ok := d.Nodes[to]
if !ok {
return nil, nil, fmt.Errorf("%v does not exist as a vertex [from: %v, to: %v]", to, from, to)
}
return fromNode, toNode, nil
}