code: def optimize(self, graph):
                  
          for center in self.centers:
              shortest_routes = shortest_path(graph, center)[1]
              for node, weight in list(shortest_routes.items()):
                  self.nodes.setdefault(node, []).append(weight)
docs: Build a dictionary mapping each pair of nodes to a number (the distance between them).
          
          @type  graph: graph
          @param graph: Graph.