now the algorithm can read the weight of the graphs