graph = {
    'A': ['B', 'C'],
    'B': ['D'],
    'C': [],
    'D': [],
    'E': ['F'], # 'E' and 'F' are disconnected from 'A'
    'F': []
}

source = 'A'
visited = set()
stack = [source]

print("DFS Traversal starting from node", source, ":")

while stack:
    x = stack.pop()
    
    if x not in visited:
        visited.add(x)
        print(x, end=" ")
        
        # Reverse neighbors before pushing so they are popped in natural left-to-right order
        for v in reversed(graph[x]):
            if v not in visited:
                stack.append(v)