Someone
public python v1 · immutablesparse_matrix, these_links, last_link_from = [], [1], 1for link_from, link_to in wikipedia_links: if link_from != last_link_from: sparse_matrix.append(these_links) while link_from != last_link_from+1: sparse_matrix.append([]) last_link_from += 1 these_links = [int(link_from)] if link_to <= wikipedia_links[-1][0]-1: these_links.append(int(link_to)) last_link_from = link_from