-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (34 loc) · 1.4 KB
/
main.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
'''
Author: Zhiqiang
Date: 2020.12.11
Description: This project is to generate the relation graph among
requested permissions of Android apps in one genre.
'''
import networkx as nx
from tqdm import tqdm
import matplotlib.pyplot as plt
import buildGraph as bg
from utils import normalization, searchCommon, freqPermission, weightProportion
if __name__ == '__main__':
print("Loading permission list from csv...")
categories, permissions, data = bg.dataReader()
print("Starting graph generation...")
pbar = tqdm(total=len(categories))
for category in categories:
print("Creating graph for permission {}".format('Art & Design'))
graph = bg.buildGraph('Art & Design', permissions, data.groupby('category').get_group('Art & Design'))
nx.draw(graph, with_labels=True, node_size=1000, pos= nx.shell_layout(graph))
plt.show()
pbar.update(1)
#print(graph.nodes.data())
adj_matrix = bg.weightMatrix(graph, mtype='weight')
print('-------------------Weight matrix-------------------')
print(adj_matrix)
degree_matrix = bg.degreeMatrix(graph)
print('-------------------Degree matrix-------------------')
print(degree_matrix)
print('-------------------Normalized matrix-------------------')
print(normalization(adj_matrix))
print(searchCommon(graph))
break
pbar.close()