implemented edge distance calculation and file creation logic