《Redis使用手册》(试读版)# 为了⼀次对图中的多条边进⾏设置 # 我们要将待设置的各条边以及它们的权重储存在以下字典 nodes_and_weights = {} # 遍历输⼊的每个三元组,从中取出边的起点、终点和权重 for start, end, weight in tuples: # 根据边的起点和终点,创建出边的名字 # 为了⼀次获取图中多条边的权重 # 我们需要把所有想要获取权重的边的名字依次放⼊到以下列表⾥⾯ edge_list = [] # 遍历输⼊的每个⼆元组,从中获取边的起点和终点 for start, end in tuples: # 根据边的起点和终点,创建出边的名字 edges = self.client.hkeys(self.key) # 创建⼀个集合,⽤于储存⼆元组格式的边 result = set() # 遍历每条边的名字 for edge in edges: # 根据边的名字,分解出边的起点和终点 start, end = decom0 码力 | 352 页 | 6.57 MB | 1 年前3
共 1 条
- 1













