Beispiel #1
0
    def test_indegree_positive_trivial(self):
        votes = VoteMatrix(4)

        votes.positive[0, 1] = 1
        votes.positive[1, 2] = 1
        votes.positive[2, 3] = 1
        votes.positive[3, 0] = 1

        in_degree = InDegreePositive()

        m = in_degree.apply(votes)

        assert len(m) == 4
        for score in m:
            assert score == 0.25
Beispiel #2
0
    def test_indegree_positive(self):
        votes = VoteMatrix(4)

        votes.positive[0, 1] = 1
        votes.positive[0, 2] = 1
        votes.positive[2, 1] = 1
        votes.positive[3, 0] = 1
        votes.positive[3, 2] = 4

        in_degree = InDegreePositive()

        m = in_degree.apply(votes)

        assert numpy.abs(m[0] - 0.125) < 0.001
        assert numpy.abs(m[1] - 0.250) < 0.001
        assert numpy.abs(m[2] - 0.625) < 0.001
        assert numpy.abs(m[3] - 0.000) < 0.001
from simulation.community import ActionProfile
from simulation.member import Member

if __name__ == '__main__':
    """
    In this test, it is evaluated how many friends who are significantly less competent
    than their peers are required to trick the system so that they reach top position
    in the reputation ranking.
    """

    test_name = "Friends"
    community = OnlineDiscussionGroup()

    ALL_CENTRALITY_SCORES = [
        PageRank(), EigenTrust(),
        InDegree(), InDegreePositive()
    ]

    # Possible Actions
    actions: ActionProfile = community.action_profile

    # Group unaffiliated
    num_unaffiliated = 25

    unaffiliated = Member("unaffiliated", [
        (0.27, actions.post_good_comment),
        (0.03, actions.post_bad_comment),
        (0.32, actions.vote_bad_comment_negative),
        (0.03, actions.vote_any_comment_negative),
        (0.32, actions.vote_good_comment_positive),
        (0.03, actions.vote_any_comment_positive),