'''simple docstring'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       Optional[Any]:
    __lowerCamelCase            =    [0] * len(UpperCamelCase__							)
    __lowerCamelCase            =    []
    __lowerCamelCase            =    []
    __lowerCamelCase            =    0

    for values in graph.values():
        for i in values:
            indegree[i] += 1

    for i in range(len(UpperCamelCase__							)							):
        if indegree[i] == 0:
            queue.append(UpperCamelCase__							)

    while queue:
        __lowerCamelCase            =    queue.pop(0							)
        cnt += 1
        topo.append(UpperCamelCase__							)
        for x in graph[vertex]:
            indegree[x] -= 1
            if indegree[x] == 0:
                queue.append(UpperCamelCase__							)

    if cnt != len(UpperCamelCase__							):
        print('''Cycle exists'''							)
    else:
        print(UpperCamelCase__							)


# Adjacency List of Graph
__UpperCAmelCase					={0: [1, 2], 1: [3], 2: [3], 3: [4, 5], 4: [], 5: []}



topological_sort(graph)

'''simple docstring'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       float:
    __lowerCamelCase            =    0
    while len(UpperCamelCase__							) > 1:
        __lowerCamelCase            =    0
        # Consider two files with minimum cost to be merged
        for _ in range(2							):
            __lowerCamelCase            =    files.index(min(UpperCamelCase__							)							)
            temp += files[min_index]
            files.pop(UpperCamelCase__							)
        files.append(UpperCamelCase__							)
        optimal_merge_cost += temp
    return optimal_merge_cost


if __name__ == "__main__":
  import doctest

  doctest.testmod()
