def optimize(self, graph):
for start in graph.nodes():<EOL><INDENT>for end in graph.nodes():<EOL><INDENT>for each in graph.node_attributes(start):<EOL><INDENT>if (each[<NUM_LIT:0>] == '<STR_LIT>'):<EOL><INDENT>start_attr = each[<NUM_LIT:1>]<EOL>break<EOL><DEDENT><DEDENT>for each in graph.node_attributes(end):<EOL><INDENT>if (each[<NUM_LIT:0>] == '<STR_LIT>'):<EOL><INDENT>end_attr = each[<NUM_LIT:1>]<EOL>break<EOL><DEDENT><DEDENT>dist = <NUM_LIT:0><EOL>for i in range(len(start_attr)):<EOL><INDENT>dist = dist + (float(start_attr[i]) - float(end_attr[i]))**<NUM_LIT:2><EOL><DEDENT>self.distances[(start,end)] = dist<EOL><DEDENT><DEDENT>
Build a dictionary mapping each pair of nodes to a number (the distance between them).

@type  graph: graph
@param graph: Graph.