def find_dead_ends(graph, start_node, width):
    """Find dead ends in a graph."""

    dead_ends = []
    def collect_dead_ends(node):
        x = node[0]
        # do not consider dead ends on the right side of the maze, as those
        # represents passages to the enemy's side
        if graph.degree(node) == 1 and x < width - 1:
            dead_ends.append(node)

    for node in nx.bfs_successors(graph, start_node):
        collect_dead_ends(node)

    return dead_ends
dataset/ETHPy150Open ASPP/pelita/layouts/maze_generator.py/find_dead_ends/original