RewireNetwork() corrected and improved for weighted case