(ugraph, start_node)
return set(visited)
输入无向图ugraph和一个节点start_node
    返回从这个节点出发，通过广度优先搜索访问的所有节点的集合
输入无向图ugraph和一个节点start_node
    返回从这个节点出发，通过广度优先搜索访问的所有节点的集合
输入无向图ugraph和一个节点start_node 返回从这个节点出发，通过广度优先搜索访问的所有节点的集合
def bfs_visited(ugraph, start_node):
    """
    输入无向图ugraph和一个节点start_node
    返回从这个节点出发，通过广度优先搜索访问的所有节点的集合
    """
    # initialize Q to be an empty queue
    que = deque()
    # initialize visited
    visited = [start_node]
    # enqueue(que, start_node)
    que.append(start_node)
    while len(que) > 0:
        current_node = que.popleft()
        neighbours = ugraph[current_node]
        for nei in neighbours:
            if nei not in visited:
                visited.append(nei)
                que.append(nei) 
    return set(visited)
def bfs_visited ( ugraph , start_node ) : # initialize Q to be an empty queue que = deque ( ) # initialize visited visited = [ start_node ] # enqueue(que, start_node) que . append ( start_node ) while len ( que ) > 0 : current_node = que . popleft ( ) neighbours = ugraph [ current_node ] for nei in neighbours : if nei not in visited : visited . append ( nei ) que . append ( nei ) return set ( visited )