-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
63 lines (41 loc) · 1.44 KB
/
controller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os, json
import networkx as nx
from connection import scrap_relations, check_mail
from graph import relations_graph_attach, analysis, community_analysis, simulate_spread, save, load, draw, connected, \
draw_infected
from plotting import flaw_bar_plot
def domain2graph(domain, depth):
G = nx.Graph()
relations = scrap_relations(domain, depth)
relations_graph_attach(G, relations)
return G
def graph2flaws(G):
flaws = dict()
for mail in G.nodes():
flaws[mail] = check_mail(mail)
nx.set_node_attributes(G, flaws, 'flaws')
return G
def graph_save(G, path):
save(G, path)
def graph_load(path):
try:
return load(path)
except:
print("Graph not found.")
def graph_connected(G, strategy):
G = connected(G, strategy)
return G
def graph_analysis(G, output):
analysis(G, output)
def graph_draw(G, output):
draw(G, output)
def graph_community_analysis(G, output):
community_analysis(G, output)
def graph_simulate_spread(G, steps, threshold, infected_probability, simulation_beta, simulation_gamma,
simulation_alpha, output):
return simulate_spread(G, steps, threshold, infected_probability, simulation_beta, simulation_gamma,
simulation_alpha, output)
def graph_draw_infected(G, infected_nodes, output):
draw_infected(G, infected_nodes, output)
def graph_flaw_bar_plot(G, output):
flaw_bar_plot(G, output)