code: def computePairwisePreferences(self, profile):
          
  
          cands = profile.candMap.keys()
  
          # Initialize the two-dimensional dictionary that will hold our pairwise preferences.
          pairwisePreferences = dict()
          for cand in cands:
              pairwisePreferences[cand] = dict()
          for cand1 in cands:
              for cand2 in cands:
                  if cand1 != cand2:
                      pairwisePreferences[cand1][cand2] = 0
  
          for preference in profile.preferences:
              wmgMap = preference.wmgMap
              for cand1, cand2 in itertools.combinations(cands, 2):
  
                  # If either candidate was unranked, we assume that they are lower ranked than all
                  # ranked candidates.
                  if cand1 not in wmgMap.keys():
                      if cand2 in wmgMap.keys():
                          pairwisePreferences[cand2][cand1] += 1 * preference.count
                  elif cand2 not in wmgMap.keys():
                      if cand1 in wmgMap.keys():
                          pairwisePreferences[cand1][cand2] += 1 * preference.count
  
                  elif wmgMap[cand1][cand2] == 1:
                      pairwisePreferences[cand1][cand2] += 1 * preference.count
                  elif wmgMap[cand1][cand2] == -1:
                      pairwisePreferences[cand2][cand1] += 1 * preference.count
  
          return pairwisePreferences
docs: Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and
          cand2, with number of voters who prefer cand1 to cand2.
  
          :ivar Profile profile: A Profile object that represents an election profile.