(self, graph)
Build a dictionary mapping each pair of nodes to a number (the distance between them).
        
        @type  graph: graph
        @param graph: Graph.
Build a dictionary mapping each pair of nodes to a number (the distance between them).
Build a dictionary mapping each pair of nodes to a number ( the distance between them ) .
def optimize(self, graph):
        """
        Build a dictionary mapping each pair of nodes to a number (the distance between them).
        
        @type  graph: graph
        @param graph: 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)
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 )