//----< Generate dependency graph based on dependency table >-------------- public CsGraph<string, string> Creat_Graph(string[] args){ DepenAnalysis dep = new DepenAnalysis(); dep = dep.DepenAnalysises(args); CsGraph<string, string> Depen_Graph = new CsGraph<string, string>("Dep_Table"); CsNode<string, string> Depen_node_one = new CsNode<string, string>("node"); List<CsNode<string, string>> node_container = new List<CsNode<string, string>>(); List<string> temp = new List<string>(); foreach (var files in args){ if (!temp.Contains(System.IO.Path.GetFileName(files))){ temp.Add(System.IO.Path.GetFileName(files)); } else continue; } foreach (var file in temp){ CsNode<string, string> nodes = new CsNode<string, string>(file); Depen_node_one = nodes; node_container.Add(nodes); } gett(dep.DepTable, node_container); foreach (var elem in node_container){ Depen_Graph.addNode(elem); } Depen_Graph.startNode = Depen_node_one; return Depen_Graph; }
//----< find Strong conponent based on tarjan alforithm >-------------- public void SC_finder(CsNode<V, E> node) { node.t_normalnum = node.min_num = ++dfn_index; node_stack.Push(node); foreach (var item in node.children) { if (item.targetNode.t_normalnum < 0) { SC_finder(item.targetNode); node.min_num = Math.Min(item.targetNode.min_num, node.min_num); } else if (node_stack.Contains(item.targetNode)) { node.min_num = Math.Min(node.min_num, item.targetNode.min_num); } } if(node.t_normalnum == node.min_num) { SClist.Add("\n Find a Strong Conponent: "); Console.Write("\n Find a Strong Conponent: "); CsNode<V, E> new_node; do { new_node = node_stack.Pop(); SClist.Add(new_node.name + ", "); Console.Write(new_node.name + ", "); } while (new_node != node); } }
//----< add child vertex and its associated edge value to vertex >----- public void addChild(CsNode<V, E> childNode, E edgeVal) { children.Add(new CsEdge<V, E>(childNode, edgeVal)); }
public CsEdge(CsNode<V, E> node, E value) { targetNode = node; edgeValue = value; }
//----< add vertex to graph adjacency list >--------------------------- public void addNode(CsNode<V, E> node) { adjList.Add(node); }
//----< graph.walk() calls this on every node >------------------------ virtual public bool doNodeOp(CsNode<V, E> node) { Console.Write("\n {0}", node.ToString()); return true; }