# Sample graph represented as an adjacency list #dictionary graph = { 'A': ['B', 'C'], 'B': ['D', 'E'], 'C': ['F'], 'D': [], 'E': ['F'], 'F': [] } visited = set() def dfs(graph, vertex): visited.add(vertex) print(vertex) for neighbor in graph[vertex]: if neighbor not in visited: dfs(graph, neighbor) # Starting DFS from vertex 'A' dfs(graph, 'A')