def listdict_to_listlist_and_matrix(sparse):
    """Transforms the adjacency list representation of a graph
    of type listdict into the listlist + weight matrix representation

    :param sparse: graph in listdict representation
    :returns: couple with listlist representation, and weight matrix
    :complexity: linear
    """
    V = range(len(sparse))
    graph = [[] for _ in V]
    weight = [[None for v in V] for u in V]
    for u in V:
        for v in sparse[u]:
            graph[u].append(v)
            weight[u][v] = sparse[u][v]
    return graph, weight