Added code to generate edge weights