diff --git a/compsoc/profile.py b/compsoc/profile.py index 6d5dbfd..95dc511 100644 --- a/compsoc/profile.py +++ b/compsoc/profile.py @@ -60,6 +60,7 @@ def __init__(self, pairs: Set[Tuple[int, Tuple[int, ...]]], num_candidates: Opti self.__calc_votes_per_candidate() # Initialize a Path Preference Graph self.path_preference_graph = {candidate: {} for candidate in self.candidates} + self.__calc_path_preference() # --------------------------------------------- # Comparison routines @@ -289,7 +290,6 @@ def __calc_paths(self, candidate1, candidate2, candidates=None): # End of path if candidate == candidate2: paths.append(path) # add to possible paths - path = [] # start a new path else: # path isn't over new_candidates = candidates - {candidate} subpath = self.__calc_paths(candidate, candidate2, @@ -298,6 +298,7 @@ def __calc_paths(self, candidate1, candidate2, candidates=None): # concatenate with current path and save it for weights in subpath: paths.append(path + weights) + path = [] # start a new path # Return a list of possible paths between candidate1 and candidate2 return paths