internal static CallGraph<string, int> GenerateCallGraph(int n) { var result = new CallGraph<string,int>(); for (var i = 0; i < n; i++) { result.Add(string.Format("N{0}", i)); } // now generate the edges var rand = new Random(); for (var i = 0; i < 5 * n; i++) { var source = rand.Next(n - 1); var dest = rand.Next(n - 1); result.AddCall(string.Format("N{0}", source), string.Format("N{0}", dest)); } result.Add("Main"); result.AddRootMethod("Main"); foreach (var method in result.GetNodes()) { result.AddCall("Main", method); } return result; }
private static CallGraph<MethodDescriptor, LocationDescriptor> ReBuildCallGraph(Dispatcher dispatcher, Solution solution) { var callgraph = new CallGraph<MethodDescriptor, LocationDescriptor>(); // pg.PropagateDeletionOfNodes(); foreach (var e in dispatcher.GetAllEntites()) { var entityProcessor = new MethodEntityProcessor((MethodEntity)e, dispatcher);// e.GetEntityProcessor(dispatcher); var methodEntity = (MethodEntity)entityProcessor.Entity; if (methodEntity.MethodDescriptor.ToString().Contains("Main")) { callgraph.AddRootMethod(methodEntity.MethodDescriptor); } // Updates the callGraph UpdateCallGraph(entityProcessor, callgraph, solution); } //callgraph.Save("cg_d.dot"); return callgraph; }