// NewDfsForest execute the DFS search on a graph, traversing all nodes
NewDfsForest execute the DFS search on a graph, traversing all nodes
// NewDfsForest execute the DFS search on a graph traversing all nodes
func NewDfsForest(g graph.Graph, m implementMethod) (*Dfs, error) {
	dfsContext := &Dfs{0, []dfsTree{}, nodeAttrArray{}, edgeAttrArray{}}
	dfsContext.initialize(g)
	g.IterateAllNodes(func(k graph.NodeID) {
		if dfsContext.nodesAttr[k].nodeColor == white {
			dfsContext.forest = append(dfsContext.forest, dfsTree{k}) 
			switch m {
			case Recurse:
				dfsContext.dfsRecurseVisit(g, k)
			case StackBased:
				dfsContext.dfsStackBasedVisit(g, k, nil)
			}
		}
	})
	return dfsContext, nil
}
func NewDfsForest ( g graph . Graph , m implementMethod ) ( * Dfs , error ) { dfsContext := & Dfs { 0 , [ ] dfsTree { } , nodeAttrArray { } , edgeAttrArray { } } dfsContext . initialize ( g ) g . IterateAllNodes ( func ( k graph . NodeID ) { if dfsContext . nodesAttr [ k ] . nodeColor == white { dfsContext . forest = append ( dfsContext . forest , dfsTree { k } ) switch m { case Recurse : dfsContext . dfsRecurseVisit ( g , k ) case StackBased : dfsContext . dfsStackBasedVisit ( g , k , nil ) } } } ) return dfsContext , nil }
NewDfsForest execute the DFS search on a graph, traversing all nodes
NewDfsForest execute the DFS search on a graph traversing all nodes
// Initialize // DFS //record a tree's root // execute one tree search