Пример #1
0
        public void build_loopDAG(ref GraphVariables.clsGraph graph, int currentN, ref GraphVariables.clsLoop clsLoop, int currentLoop,
                                  ref GraphVariables.clsSESE clsSESE, ref GraphVariables.clsLoopDAG clsLoopDAG, int currentLoopDAG)
        {
            int init_n = Initialize_loopDAG(graph, currentN, clsLoop, currentLoop);

            clsLoopDAG.loopDAG[currentLoopDAG].loopDAG  = new GraphVariables.clsLoopDAG.strLoopDAGInfo[init_n];
            clsLoopDAG.loopDAG[currentLoopDAG].nLoopDAG = 0;

            //clsLoopDAG.loopDAG[currentLoopDAG].loopDAG[1].DAG.header;

            //int count_loopDAG = 0;

            for (int i = 0; i < clsLoop.Loop[currentLoop].nLoop; i++)
            {
                gProAnalyzer.GraphVariables.clsLoop.strLoopInform loop = clsLoop.Loop[currentLoop].Loop[i];
                if (loop.nEntry == 1) //NL
                {
                    gProAnalyzer.Ultilities.makeSubNetwork.make_subNetwork(ref graph, currentN, graph.acyclicNet, ref clsLoop, currentLoop, i, ref clsSESE, "FF", -1);
                }
                else //IL
                {
                }
            }
        }
Пример #2
0
        public static void add_subNatural(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, int saveN, ref gProAnalyzer.GraphVariables.clsLoop clsLoop, int workLoop, int saveLoop, int loop)
        {
            //Loop[workLoop].Loop찾기
            search_Loop(ref graph, currentN, ref clsLoop, workLoop);
            for (int i = 0; i < clsLoop.Loop[workLoop].nLoop; i++)
            {
                if (clsLoop.Loop[workLoop].Loop[i].parentLoop == -1)
                {
                    continue;
                }
                if (clsLoop.Loop[workLoop].Loop[i].Irreducible)
                {
                    continue;
                }

                int orgHeader = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[i].header].parentNum;
                if (orgHeader != clsLoop.Loop[saveLoop].Loop[loop].header)
                {
                    continue;                                                        //원 loop의 헤더를 공유하는 것만 추가
                }
                // Loop[workLoop].Loop 추가 ----------------------
                gProAnalyzer.GraphVariables.clsLoop.strLoopInform addLoop = new gProAnalyzer.GraphVariables.clsLoop.strLoopInform();
                int orgNode, orgNode2;

                addLoop = clsLoop.Loop[workLoop].Loop[i]; //일단 copy

                addLoop.depth      = clsLoop.Loop[saveLoop].Loop[loop].depth + 1;
                addLoop.parentLoop = loop;
                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nChild; k++)
                {
                    orgNode = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[clsLoop.Loop[workLoop].Loop[i].child[k]].header].parentNum;
                    int findLoop = -1;
                    for (int k2 = 0; k2 < clsLoop.Loop[saveLoop].nLoop; k2++)
                    {
                        if (orgNode == clsLoop.Loop[saveLoop].Loop[k2].header)
                        {
                            findLoop = k2;
                            break;
                        }
                    }
                    addLoop.child[k] = findLoop;
                    clsLoop.Loop[saveLoop].Loop[findLoop].parentLoop = clsLoop.Loop[saveLoop].nLoop;
                }

                orgNode        = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[i].header].parentNum;
                addLoop.header = orgNode;

                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nBackEdge; k++)
                {
                    orgNode  = graph.Network[currentN].Link[clsLoop.Loop[workLoop].Loop[i].linkBack[k]].fromNode;
                    orgNode  = graph.Network[currentN].Node[orgNode].parentNum;
                    orgNode2 = graph.Network[currentN].Link[clsLoop.Loop[workLoop].Loop[i].linkBack[k]].toNode;
                    orgNode2 = graph.Network[currentN].Node[orgNode2].parentNum;

                    int orgLink = -1;
                    for (int k2 = 0; k2 < graph.Network[saveN].nLink; k2++)
                    {
                        if (orgNode == graph.Network[saveN].Link[k2].fromNode && orgNode2 == graph.Network[saveN].Link[k2].toNode)
                        {
                            orgLink = k2;
                            break;
                        }
                    }
                    addLoop.linkBack[k] = orgLink;
                }

                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nEntry; k++)
                {
                    orgNode          = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[i].Entry[k]].parentNum;
                    addLoop.Entry[k] = orgNode;
                }

                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nExit; k++)
                {
                    orgNode         = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[i].Exit[k]].parentNum;
                    addLoop.Exit[k] = orgNode;
                }

                for (int k = 0; k < clsLoop.Loop[workLoop].Loop[i].nNode; k++)
                {
                    orgNode         = graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[i].Node[k]].parentNum;
                    addLoop.Node[k] = orgNode;
                }

                int nNewLoop = clsLoop.Loop[saveLoop].nLoop + 1;
                gProAnalyzer.GraphVariables.clsLoop.strLoop newLoop = new gProAnalyzer.GraphVariables.clsLoop.strLoop();
                newLoop.Loop = new gProAnalyzer.GraphVariables.clsLoop.strLoopInform[nNewLoop];

                for (int k = 0; k < clsLoop.Loop[saveLoop].nLoop; k++)
                {
                    newLoop.Loop[k] = clsLoop.Loop[saveLoop].Loop[k];
                    if (k == loop) //추가Loop[workLoop].Loop의 parents면
                    {
                        //----Child  추가 및 제거
                        int   numAdd = 0;
                        int[] add    = new int[clsLoop.Loop[saveLoop].Loop[k].nChild + 1];
                        for (int k2 = 0; k2 < clsLoop.Loop[saveLoop].Loop[k].nChild; k2++)
                        {
                            bool bDel = false;
                            for (int k3 = 0; k3 < addLoop.nChild; k3++)
                            {
                                if (clsLoop.Loop[saveLoop].Loop[k].child[k2] == addLoop.child[k3])
                                {
                                    bDel = true;
                                    break;
                                }
                            }
                            if (!bDel)
                            {
                                add[numAdd] = clsLoop.Loop[saveLoop].Loop[k].child[k2];
                                numAdd++;
                            }
                        }
                        add[numAdd] = clsLoop.Loop[saveLoop].nLoop;
                        numAdd++;

                        newLoop.Loop[k].nChild = numAdd;
                        newLoop.Loop[k].child  = add;

                        //-----포함 Node 제거
                        numAdd = 0;
                        add    = new int[clsLoop.Loop[saveLoop].Loop[k].nNode];
                        for (int k2 = 0; k2 < clsLoop.Loop[saveLoop].Loop[k].nNode; k2++)
                        {
                            bool bDel = false;
                            for (int k3 = 0; k3 < addLoop.nNode; k3++)
                            {
                                if (clsLoop.Loop[saveLoop].Loop[k].Node[k2] == addLoop.Node[k3])
                                {
                                    bDel = true;
                                    break;
                                }
                            }
                            if (!bDel)
                            {
                                add[numAdd] = clsLoop.Loop[saveLoop].Loop[k].Node[k2];
                                numAdd++;
                            }
                        }
                        newLoop.Loop[k].nNode = numAdd;
                        newLoop.Loop[k].Node  = add;
                    }
                }
                newLoop.Loop[clsLoop.Loop[saveLoop].nLoop] = addLoop;
                clsLoop.Loop[saveLoop].Loop  = newLoop.Loop;
                clsLoop.Loop[saveLoop].nLoop = nNewLoop;
            }
            clsLoop.Loop[saveLoop].maxDepth = 0;
            for (int i = 0; i < clsLoop.Loop[saveLoop].nLoop; i++)
            {
                if (clsLoop.Loop[saveLoop].Loop[i].depth > clsLoop.Loop[saveLoop].maxDepth)
                {
                    clsLoop.Loop[saveLoop].maxDepth = clsLoop.Loop[saveLoop].Loop[i].depth;
                }
            }
        }
Пример #3
0
        public static void merge_Loop(ref gProAnalyzer.GraphVariables.clsLoop loop, int workLoop, int parent, int child)
        {
            //loop포함 노드
            int nNewNode = loop.Loop[workLoop].Loop[parent].nNode + loop.Loop[workLoop].Loop[child].nNode;

            int[] newNode = new int[nNewNode];
            nNewNode = 0;
            for (int i = 0; i < loop.Loop[workLoop].Loop[parent].nNode; i++)
            {
                newNode[nNewNode] = loop.Loop[workLoop].Loop[parent].Node[i];
                nNewNode++;
            }
            for (int i = 0; i < loop.Loop[workLoop].Loop[child].nNode; i++)
            {
                newNode[nNewNode] = loop.Loop[workLoop].Loop[child].Node[i];
                nNewNode++;
            }

            loop.Loop[workLoop].Loop[parent].nNode = nNewNode;
            loop.Loop[workLoop].Loop[parent].Node  = newNode;

            // loop child loop
            int nNewChild = loop.Loop[workLoop].Loop[parent].nChild - 1; //PROBLEM HERE

            nNewChild = loop.Loop[workLoop].Loop[child].nChild;          //NEW CODE to store it child of child

            int[] newChild = new int[nNewChild];
            nNewChild = 0;
            for (int i = 0; i < loop.Loop[workLoop].Loop[parent].nChild; i++)
            {
                if (loop.Loop[workLoop].Loop[parent].child[i] == child)
                {
                    continue;
                }
                newChild[nNewChild] = loop.Loop[workLoop].Loop[parent].child[i];
                nNewChild++;
            }

            //add child_loop of its child
            for (int i = 0; i < loop.Loop[workLoop].Loop[child].nChild; i++)
            {
                newChild[nNewChild] = loop.Loop[workLoop].Loop[child].child[i];
                nNewChild++;
            }

            loop.Loop[workLoop].Loop[parent].nChild = nNewChild;
            loop.Loop[workLoop].Loop[parent].child  = newChild;

            //child loop 제거 (Remove child loop)
            gProAnalyzer.GraphVariables.clsLoop.strLoopInform[] newLoop = new gProAnalyzer.GraphVariables.clsLoop.strLoopInform[loop.Loop[workLoop].nLoop - 1];
            int nNewLoop = 0;

            for (int i = 0; i < loop.Loop[workLoop].nLoop; i++)
            {
                if (i == child)
                {
                    continue;
                }
                newLoop[nNewLoop] = loop.Loop[workLoop].Loop[i];
                nNewLoop++;
            }
            loop.Loop[workLoop].nLoop = nNewLoop;
            loop.Loop[workLoop].Loop  = newLoop;
            //child reNumbering
            for (int i = 0; i < loop.Loop[workLoop].nLoop; i++)
            {
                for (int k = 0; k < loop.Loop[workLoop].Loop[i].nChild; k++)
                {
                    if (loop.Loop[workLoop].Loop[i].child[k] >= child)
                    {
                        loop.Loop[workLoop].Loop[i].child[k] -= 1;
                    }
                }
            }

            //parent reNumbering
            for (int i = 0; i < loop.Loop[workLoop].nLoop; i++)
            {
                if (loop.Loop[workLoop].Loop[i].parentLoop >= child)
                {
                    loop.Loop[workLoop].Loop[i].parentLoop -= 1;
                }
            }
        }