(self,graph_list,topK)
| 642 | |
| 643 | |
| 644 | def update_cache(self,graph_list,topK): |
| 645 | merged_graph_list = self.MergeGraph(self.graph_cache,graph_list) |
| 646 | merged_graph_list = [g for g in merged_graph_list if g.GetGraphScore() > 0 and g.graph.number_of_nodes() > 10] |
| 647 | score = [x.GetGraphScore() for x in merged_graph_list] |
| 648 | if len(score) == 0: |
| 649 | return |
| 650 | print(score) |
| 651 | if len(score) < 3: |
| 652 | self.graph_cache = merged_graph_list[:topK] |
| 653 | return |
| 654 | # Different method |
| 655 | # cov = EllipticEnvelope(random_state=0).fit_predict(score) |
| 656 | # clf = OneClassSVM(kernel="rbf",gamma='auto').fit(score) |
| 657 | # cov = clf.predict(score) |
| 658 | # for g in merged_graph_list: |
| 659 | # print(g.GetGraphScore()) |
| 660 | cov = grubbs.max_test_indices(score, alpha=0.01) |
| 661 | # clf = OneClassSVM(kernel="rbf",gamma='auto').fit(score) |
| 662 | # cov = clf.predict(score) |
| 663 | # for g in merged_graph_list: |
| 664 | # print(g.GetGraphScore()) |
| 665 | for i in cov: |
| 666 | g = merged_graph_list[i].graph |
| 667 | print('[Alert]: ', score[i], len(g.nodes()),self.attack_node(g.nodes())) |
| 668 | merged_graph_list.sort(key = lambda x: x.GetGraphScore(),reverse = True) |
| 669 | |
| 670 | |
| 671 | self.graph_cache = merged_graph_list[:topK] |
| 672 | print('size of cache:',get_size(self.graph_cache)) |
| 673 | |
| 674 | def attack_node(self,node_list): |
| 675 | result = [] |
no test coverage detected