Refactoring: add weight to edge