-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (40 loc) · 1.5 KB
/
Copy pathmain.py
File metadata and controls
46 lines (40 loc) · 1.5 KB
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
import sample_ReBac as sr
import pattern_tracker as pt
import dict_to_csv as d2c
import networkx_to_csv as n2c
import rule_finder as rf
import miscellaneous_sorted.hueristic_miner as hm
import hueristic_miner2 as hm2
import lla_csv
print('starting')
# Iterations is for hueristic_miner only
iterations = 1000
max_rule_length = 5
num_nodes = 5000
num_edges = 15000
relationships = ['a', 'b', 'c', 'd', 'e']
rules = [
# ['a', 'b', 'c', 'd', 'e'],
# ['a', 'a', 'a', 'a', 'a'],
# ['e', 'd', 'c', 'b', 'a']
]
# Generating our graph
graph = sr.generate_graph(num_nodes, num_edges, relationships)
lla = sr.create_lla(graph)
lla = sr.grant_access(rules, lla, graph)
# Tracking the present and missing relationship patterns
tracker = pt.Tracker(relations= relationships.copy(), max_depth=max_rule_length) # YOU MUST MANUALLY INPUT A THE RELATIONSHIPS, YOU CANNOT USE A LIST OF RELATIONSHIPS!!!!
tracker.detect_pattern(graph)
missing = tracker.show_missing()
# If a pattern is missing from the graph, we add nodes to represent them.
# We could potentially add nodes to represent all patterns.
if missing:
sr.update_graph(graph, missing, rules)
lla = sr.create_lla(graph)
lla = sr.grant_access(rules, lla, graph)
# Implement algorithims to find policy under this line
print('\n', '1st run')
new_lla = hm2.hueristic_miner(lla, max_rule_length, relationships.copy(), graph, iterations)
lla_csv.save_lla(new_lla)
# print(rf.find_policy(graph, max_rule_length, lla, relationships.copy()))
print(lla_csv.load_lla())