def walls_to_graph(maze):
    """Transform a maze in a graph.

    The data on the nodes correspond to their coordinates, data on edges is
    the actions to take to transition to that edge.

    Returns:
    graph -- a Graph
    first_node -- the first node in the Graph
    """

    h, w = maze.shape

    graph = nx.Graph()
    # define nodes for maze
    for x in range(w):
        for y in range(h):
            if maze[y, x] != W:
                graph.add_node((x, y))

    directions = [west, east, north, south]

    # add edges
    nodes = graph.nodes()
    for pos in nodes:
        for dir_ in directions:
            neighbor = (pos[0] + dir_[0], pos[1] + dir_[1])
            if nodes in neighbor:
                graph.add_edge(pos, neighbor, data=[dir_])

    return graph, nodes[0]
dataset/ETHPy150Open ASPP/pelita/layouts/maze_generator.py/walls_to_graph/swapped operands of `in`