func FindOrder(g *graph.Graph) ([]int, error) {
	var result []int
	NumDependency := make([]int, g.NumVertexes())
	q := queue.New()
	for vd := 0; vd < g.NumVertexes(); vd++ {
		lenInEdges := len(g.InEdges(vd))
		NumDependency[vd] = lenInEdges
		if lenInEdges == 0 {
			q.Enqueue(vd)
			result = append(result, vd)
		}
	}
	for !q.IsEmpty() {
		vs := q.Dequeue()
		for _, vd := range g.OutEdges(vs) {
			NumDependency[vd]--
			if NumDependency[vd] == 0 {
				q.Enqueue(vd)
				result = append(result, vd)
			}
		}
	}
	if len(result) != g.NumVertexes() {
		return nil, errors.New("No executable order")
	}
	return result, nil
}
// FindOrder solves ch04-p07

FindOrder solves ch04-p07
// FindOrder solves ch04 - p07
func FindOrder(g *graph.Graph) ([]int, error) {
	var result []int
	NumDependency := make([]int, g.NumVertexes())
	q := queue.New()
	for vd := 0; vd < g.NumVertexes(); vd++ {
		lenInEdges := len(g.InEdges(vd))
		NumDependency[vd] = lenInEdges
		if lenInEdges == 0 {
			q.Enqueue(vd)
			result = append(result, vd)
		}
	}
	for !q.IsEmpty() {
		vs := q.Dequeue()
		for _, vd := range g.OutEdges(vs) {
			NumDependency[vd]--
			if NumDependency[vd] == 0 {
				q.Enqueue(vd)
				result = append(result, vd)
			}
		}
	}
	if len(result) != g.NumVertexes() {
		return nil, errors.New("No executable order")
	}
	return result, nil
}
func FindOrder ( g * graph . Graph ) ( [ ] int , error ) { var result [ ] int NumDependency := make ( [ ] int , g . NumVertexes ( ) ) q := queue . New ( ) for vd := 0 ; vd < g . NumVertexes ( ) ; vd ++ { lenInEdges := len ( g . InEdges ( vd ) ) NumDependency [ vd ] = lenInEdges if lenInEdges == 0 { q . Enqueue ( vd ) result = append ( result , vd ) } } for ! q . IsEmpty ( ) { vs := q . Dequeue ( ) for _ , vd := range g . OutEdges ( vs ) { NumDependency [ vd ] -- if NumDependency [ vd ] == 0 { q . Enqueue ( vd ) result = append ( result , vd ) } } } if len ( result ) != g . NumVertexes ( ) { return nil , errors . New ( " " ) } return result , nil }
FindOrder solves ch04-p07
FindOrder solves ch04 - p07