Exemplo n.º 1
0
def test(graph_params):
    graph = graphs.generators.group_based.generate(graph_params)
    group_graph = algorithms.SybilGroupRank(graph, algorithm_options).rank()
    output1 = generate_output(graph)

    reset_ranks(graph)
    group_graph = algorithms.SybilRank(graph, algorithm_options).rank()
    output2 = generate_output(graph)

    reset_ranks(graph)
    group_graph = algorithms.GroupSybilRank(graph, algorithm_options).rank()
    output3 = generate_output(graph)

    return [output1, output2, output3]
Exemplo n.º 2
0
# add_sybils(graph, sybil_edges6, 'sybil6')
# add_sybils(graph, sybil_edges7, 'sybil7')
# add_sybils(graph, sybil_edges8, 'sybil8')
# add_sybils(graph, sybil_edges9, 'sybil9')
# add_sybils(graph, sybil_edges10, 'sybil10')

outputs = []

# ranker = algorithms.SybilRank(graph, algorithm_options)
# ranker.rank()
# outputs.append(generate_output(graph, 'SybilRank'))
# draw_graph(graph, os.path.join(OUTPUT_FOLDER, 'SybilRank.html'))
#
# reset_ranks(graph)

ranker = algorithms.SybilGroupRank(graph, algorithm_options)
ranker.rank()
outputs.append(generate_output(graph, 'SybilGroupRank'))
draw_graph(graph, os.path.join(OUTPUT_FOLDER, 'SybilGroupRank.html'))

reset_ranks(graph)

# ranker = algorithms.GroupSybilRank(graph, algorithm_options)
# ranker.rank()
# outputs.append(generate_output(graph, 'IntraGroupWeight'))
# draw_graph(graph, os.path.join(OUTPUT_FOLDER, 'IntraGroupWeight.html'))
#
# reset_ranks(graph)

algorithm_options['weaken_seed'] = 5000
Exemplo n.º 3
0
            for node_name in edge
        ]
        for node_name in edge:
            if node_name not in nodes_dic:
                nodes_dic[node_name] = Node(node_name,
                                            'Sybil',
                                            groups=set(['sybils']))
        edges.append((nodes_dic[edge[0]], nodes_dic[edge[1]]))
    graph.add_edges_from(edges)
    sybils = [node for node in nodes_dic.values() if node.node_type == 'Sybil']
    for sybil in sybils:
        for neighbour in graph.neighbors(sybil):
            if neighbour.node_type != 'Sybil':
                # neighbour.node_type = 'Attacker'
                neighbour.groups.add('sybils')


graph = load_graph('inputs/graph.json')
add_sybils(graph, 'inputs/sybils.txt')
ranker = algorithms.SybilGroupRank(
    graph, {
        'min_degree': 5,
        'accumulative': False,
        'weaken_under_min': True,
        'nonlinear_distribution': True,
        'group_edge_weight': 2
    })
ranker.rank()
output = generate_output(graph)
write_output_file([output], os.path.join(OUTPUT_FOLDER, 'result.csv'))
draw_graph(graph, os.path.join(OUTPUT_FOLDER, 'nodes.html'))