| 30 | # Prepare the call graph |
| 31 | |
| 32 | def build_call_graph(xml_dir): |
| 33 | print('Building the call graph for ' + xml_dir) |
| 34 | |
| 35 | graph = nx.DiGraph() |
| 36 | func2file = {} |
| 37 | |
| 38 | for xml in glob.glob(xml_dir + '/**/*.[ch].xml', recursive=True): |
| 39 | tree = etree.parse(xml) |
| 40 | roots = [tree.getroot()] |
| 41 | _, _, f2f = call_graph.c.build_call_graph(roots, G=graph) |
| 42 | for func, fname in f2f.items(): |
| 43 | func2file[func] = fname |
| 44 | print("Number of nodes: {}".format(len(graph.nodes()))) |
| 45 | print("Number of edges: {}".format(len(graph.edges()))) |
| 46 | n = nx.number_weakly_connected_components(graph) |
| 47 | print("Number of connected components: {}".format(n)) |
| 48 | return graph, func2file |
| 49 | |
| 50 | def pagerank_c(graph, alpha_low, alpha_high, alpha_step): |
| 51 | pra = [] |