graph = {
  'A' : ['B','C'],
  'B' : ['D', 'E'],
  'C' : ['F'],
  'D' : ['A', 'B'],
  'E' : ['F'],
  'F' : ['F', 'C'],
  'G' : ['C', 'E'],
  'H' : ['A', 'F']
}

def dfs(graph, vertex):
    visited = set()

    def dfs_recursive(graph, vertex):
        visited.add(vertex)
        print("visitando: " + vertex)
        for neighbor in graph[vertex]:
            if vertex == 'E':
                print("me achou")
                break
            if neighbor not in visited:
                dfs_recursive(graph, neighbor) 

    dfs_recursive(graph, vertex)        

dfs(graph, 'A')

621d99b30398065a90e2891f77413b17bc89ea8d
<mask token>

<mask token>


def dfs(graph, vertex):
    visited = set()

    def dfs_recursive(graph, vertex):
        visited.add(vertex)
        print('visitando: ' + vertex)
        for neighbor in graph[vertex]:
            if vertex == 'E':
                print('me achou')
                break
            if neighbor not in visited:
                dfs_recursive(graph, neighbor)
    dfs_recursive(graph, vertex)


<mask token>

<mask token>


def dfs(graph, vertex):
    visited = set()

    def dfs_recursive(graph, vertex):
        visited.add(vertex)
        print('visitando: ' + vertex)
        for neighbor in graph[vertex]:
            if vertex == 'E':
                print('me achou')
                break
            if neighbor not in visited:
                dfs_recursive(graph, neighbor)
    dfs_recursive(graph, vertex)


dfs(graph, 'A')

graph = {'A': ['B', 'C'], 'B': ['D', 'E'], 'C': ['F'], 'D': ['A', 'B'], 'E':
    ['F'], 'F': ['F', 'C'], 'G': ['C', 'E'], 'H': ['A', 'F']}


def dfs(graph, vertex):
    visited = set()

    def dfs_recursive(graph, vertex):
        visited.add(vertex)
        print('visitando: ' + vertex)
        for neighbor in graph[vertex]:
            if vertex == 'E':
                print('me achou')
                break
            if neighbor not in visited:
                dfs_recursive(graph, neighbor)
    dfs_recursive(graph, vertex)


dfs(graph, 'A')

graph = {
  'A' : ['B','C'],
  'B' : ['D', 'E'],
  'C' : ['F'],
  'D' : ['A', 'B'],
  'E' : ['F'],
  'F' : ['F', 'C'],
  'G' : ['C', 'E'],
  'H' : ['A', 'F']
}

def dfs(graph, vertex):
    visited = set()

    def dfs_recursive(graph, vertex):
        visited.add(vertex)
        print("visitando: " + vertex)
        for neighbor in graph[vertex]:
            if vertex == 'E':
                print("me achou")
                break
            if neighbor not in visited:
                dfs_recursive(graph, neighbor) 

    dfs_recursive(graph, vertex)        

dfs(graph, 'A')
