All pastes #803088 Raw Edit

aib

public python v1 · immutable
#803088 ·published 2007-11-30 21:48 UTC
rendered paste body
sparse_matrix = []for k,g in groupby(wikipedia_links, key=itemgetter(0)):    sparse_matrix.append([k] + map(itemgetter(1), g)"""Old code (new code doesn't cover _all_ the same functionality, but most of itsparse_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"""