def getCandScoresMap(self, profile):
        """
        Returns a dictionary that associates integer representations of each candidate with their
        Copeland score.

        :ivar Profile profile: A Profile object that represents an election profile.
        """

        # Currently, we expect the profile to contain complete ordering over candidates. Ties are
        # allowed however.
        elecType = profile.getElecType()
        if elecType != "soc" and elecType != "toc":
            print("ERROR: unsupported election type")
            exit()

        # Initialize each Copeland score as 0.0.
        copelandScores = dict()
        for cand in profile.candMap.keys():
            copelandScores[cand] = 0.0

        preferenceCounts = profile.getPreferenceCounts()

        # For each pair of candidates, calculate the number of votes in which one beat the other.
        wmgMap = profile.getWmg()
        for cand1, cand2 in itertools.combinations(wmgMap.keys(), 2):
            if cand2 in wmgMap[cand1].keys():
                if wmgMap[cand1][cand2] > 0:
                    copelandScores[cand1] += 1.0
                elif wmgMap[cand1][cand2] < 0:
                    copelandScores[cand2] += 1.0

                # If a pair of candidates is tied, we add alpha to their score for each vote.
                else:
                    copelandScores[cand1] += self.alpha
                    copelandScores[cand2] += self.alpha

        return copelandScores
def getCandScoresMap ( self , profile ) : elecType = profile . getElecType ( ) if elecType != "soc" and elecType != "toc" : print ( "ERROR: unsupported election type" ) exit ( ) copelandScores = dict ( ) for cand in profile . candMap . keys ( ) : copelandScores [ cand ] = 0.0 preferenceCounts = profile . getPreferenceCounts ( ) wmgMap = profile . getWmg ( ) for cand1 , cand2 in itertools . combinations ( wmgMap . keys ( ) , 2 ) : if cand2 in wmgMap [ cand1 ] . keys ( ) : if wmgMap [ cand1 ] [ cand2 ] > 0 : copelandScores [ cand1 ] += 1.0 elif wmgMap [ cand1 ] [ cand2 ] < 0 : copelandScores [ cand2 ] += 1.0 else : copelandScores [ cand1 ] += self . alpha copelandScores [ cand2 ] += self . alpha return copelandScores
Returns a dictionary that associates integer representations of each candidate with their
        Copeland score.

        :ivar Profile profile: A Profile object that represents an election profile.