//----< build dependency graph from dependency table >----------- public CsGraph <string, string> buildDependencyGraph() { var repo = Repository.getInstance(); var graph = new CsGraph <string, string>("deps"); foreach (var item in repo.dependencyTable.dependencies) { var fileName = item.Key; fileName = Path.GetFileName(fileName); var node = new CsNode <string, string>(fileName); graph.addNode(node); } var dt = new DependencyTable(); foreach (var item in repo.dependencyTable.dependencies) { var fileName = item.Key; fileName = Path.GetFileName(fileName); if (!dt.dependencies.ContainsKey(fileName)) { var deps = new List <string>(); dt.dependencies.Add(fileName, deps); } foreach (var elem in item.Value) { var childFile = elem; childFile = Path.GetFileName(childFile); dt.dependencies[fileName].Add(childFile); } } foreach (var item in graph.adjList) { var node = item; var children = dt.dependencies[node.name]; foreach (var child in children) { var index = graph.findNodeByName(child); if (index != -1) { var dep = graph.adjList[index]; node.addChild(dep, "edge"); } } } return(graph); }
//-------------<Add node to the graph>----------- public void addNode(CsNode <string, string> node) { graph_.addNode(node); }