python zip玩法

import numpy as np
graph = [(0, 1), (1, 5), (1, 7), (4, 5), (4, 8), (1, 6), (3, 7), (5, 9),(2, 4), (0, 4), (2, 5), (3, 6), (8, 9)]
rows = np.array(list(zip(*graph))[0])
cols = np.array(list(zip(*graph))[1])
data = np.ones(len(graph))
edges = zip(rows.tolist(), cols.tolist())

原文地址:https://www.cnblogs.com/kalicener/p/15465135.html