func (d *DAG) Order() int {
	numVertices := d.vertices.Size()
	return numVertices
}
Order return the number of vertices in the graph.
package dag
import (
	"fmt"
	"sync"
	"github.com/goombaio/orderedmap"
)
type DAG struct {
	mu       sync.Mutex
	vertices orderedmap.OrderedMap
}
func NewDAG() *DAG {
	d := &DAG{
		vertices: *orderedmap.NewOrderedMap(),
	}
	return d
}
func (d *DAG) AddVertex(v *Vertex) error {
	d.mu.Lock()
	defer d.mu.Unlock()
	d.vertices.Put(v.ID, v)
	return nil
}
func (d *DAG) DeleteVertex(vertex *Vertex) error {
	existsVertex := false
	d.mu.Lock()
	defer d.mu.Unlock()
	for _, v := range d.vertices.Values() {
		if v == vertex {
			existsVertex = true
		}
	}
	if !existsVertex {
		return fmt.Errorf("Vertex with ID %v not found", vertex.ID)
	}
	d.vertices.Remove(vertex.ID)
	return nil
}
func (d *DAG) AddEdge(tailVertex *Vertex, headVertex *Vertex) error {
	tailExists := false
	headExists := false
	d.mu.Lock()
	defer d.mu.Unlock()
	for _, vertex := range d.vertices.Values() {
		if vertex == tailVertex {
			tailExists = true
		}
		if vertex == headVertex {
			headExists = true
		}
	}
	if !tailExists {
		return fmt.Errorf("Vertex with ID %v not found", tailVertex.ID)
	}
	if !headExists {
		return fmt.Errorf("Vertex with ID %v not found", headVertex.ID)
	}
	for _, childVertex := range tailVertex.Children.Values() {
		if childVertex == headVertex {
			return fmt.Errorf("Edge (%v,%v) already exists", tailVertex.ID, headVertex.ID)
		}
	}
	tailVertex.Children.Add(headVertex)
	headVertex.Parents.Add(tailVertex)
	return nil
}
func (d *DAG) DeleteEdge(tailVertex *Vertex, headVertex *Vertex) error {
	for _, childVertex := range tailVertex.Children.Values() {
		if childVertex == headVertex {
			tailVertex.Children.Remove(childVertex)
		}
	}
	return nil
}
func (d *DAG) GetVertex(id interface{}) (*Vertex, error) {
	var vertex *Vertex
	v, found := d.vertices.Get(id)
	if !found {
		return vertex, fmt.Errorf("vertex %s not found in the graph", id)
	}
	vertex = v.(*Vertex)
	return vertex, nil
}