A BFS and DFS implementation
Clarification (OK)
After update of your question, it has gotten clear that:

you work on a DAG, which includes a Tree
both your strategies DFS and BFS are in Pre-Order


=&gt; original answer requesting clarification from the OP
Review Definitions
Before being able to review your code, I would like to review your definitions. Perhaps you should clarify your algorithm with examples.

I believe this code prints both the DFS and BFS of a directed graph.

How do you decide the breadth level of a node when it has multiple parents? Or would you only work with Tree instead of DAG?

As a reminder of the difference:
DFS (Depth first search) starts with a given node and explores the
first unexplored node it comes across before returning to itself again
and exploring its remaining nodes (e.g: if the parent node 1 has 2
children 2, 3 the DFS method will explore 2 and its children nodes
before exploring 3

Because you say to explore remaining nodes before returning to self, you are not very clear whether the order is A or B.

(A) 1 -&gt; 2 -&gt; 3
(B) 2 -&gt; 3 -&gt; 1


BFS (Breadth first search) works down a tree in a top-to-bottom manner
(e.g: a graph with parent 1 and children 2, 3 will print level 1 first
(1) then level 2 (2, 3) and then level 3 (the children of nodes 2 and
3)

The order is independant of search strategy (DFS/BFS). BFS can be both top-to-bottom or bottom-to-top.

Terminology

DFS: process each child completely before processing the next child
BFS: process each level across childs before processing the next level
Pre-Order: process self before rest of tree
Post-Order: process rest of tree before self

In your example of parent 1 having child 2 and child 3:

DFS Pre-Order: 1 -&gt; 2 -&gt; 3
DFS Post-Order: 2 -&gt; 3 -&gt; 1
BFS Pre-Order: 1 -&gt; 2 -&gt; 3
BFS Post-Order: 2 -&gt; 3 -&gt; 1

Suppose 2 would have its own child 4:

DFS Pre-Order: 1 -&gt; 2 -&gt; 4 -&gt; 3
DFS Post-Order: 4 -&gt; 2 -&gt; 3 -&gt; 1
BFS Pre-Order: 1 -&gt; 2 -&gt; 3 -&gt; 4
BFS Post-Order: 4 -&gt; 2 -&gt; 3 -&gt; 1

You could even add a third dimension direction in which case we distinguish left-to-right and right-to-left.