Пример #1
0
        // VERIFY all rules except R3 in a general product
        public static void CPCCDAllRules_R3(double Alfa, List <List <int> > Modules, List <List <List <int> > > Communities, List <double> Modularity, List <double[, ]> SubGraphs, List <List <ComponentStruct> > SubVerticeMs, List <int[, ]> SubRelativeMs,
                                            double[] SizeLimit, int[] CFTypeCode, int[] MaterialList, out double[,] WMNode, out List <List <int> > TroubleNodeList, out List <int> TroubleCode, out List <List <int> > NodeGroups)
        {
            int NumOfModules = Communities.Count;
            int NumOfNodes   = 0;

            for (int i = 0; i < Modules.Count; i++)
            {
                NumOfNodes += Modules[i].Count;
            }

            double[,] T_WMNode;
            List <List <int> > T_TroubleNodeList;
            List <int>         T_TroubleCode;
            List <List <int> > T_NodeGroups;
            List <List <int> > GlobalTroubleNodeList;
            List <int>         GlobalTroubleCode;

            TroubleNodeList = new List <List <int> >();
            TroubleCode     = new List <int>();
            WMNode          = new double[NumOfNodes, NumOfNodes];
            NodeGroups      = new List <List <int> >();


            for (int i = 0; i < NumOfModules; i++)
            {
                if (Modularity[i] >= Alfa)
                {
                    // apply MPCCD in this module
                    MPCCD.MPCCDAllRules_R3(Communities[i], SubGraphs[i], SubVerticeMs[i], SubRelativeMs[i], SizeLimit, CFTypeCode, MaterialList, out T_WMNode, out T_TroubleNodeList, out T_TroubleCode, out T_NodeGroups);
                }
                else
                {
                    // apply NPCCD in this module
                    NPCCD.NPCCDAllRules_R3(SubGraphs[i], SubVerticeMs[i], SizeLimit, MaterialList, SubRelativeMs[i], CFTypeCode, out T_WMNode, out T_TroubleNodeList, out T_TroubleCode, out T_NodeGroups);
                }

                MPCCD.MPCCDTransLocalToGlobal(Modules[i], T_TroubleNodeList, T_TroubleCode, T_NodeGroups, out GlobalTroubleNodeList, out GlobalTroubleCode);
                TroubleNodeList.AddRange(GlobalTroubleNodeList.ToList());
                TroubleCode.AddRange(GlobalTroubleCode.ToList());
                // translate the surviving submodules to a whole global groph
                for (int j = 0; j < T_WMNode.GetLength(0); j++)
                {
                    for (int k = 0; k < T_WMNode.GetLength(0); k++)
                    {
                        if (T_WMNode[j, k] != 0)
                        {
                            WMNode[Modules[i].ElementAt(j) - 1, Modules[i].ElementAt(k) - 1] = T_WMNode[j, k];
                            WMNode[Modules[i].ElementAt(k) - 1, Modules[i].ElementAt(j) - 1] = T_WMNode[k, j];
                        }
                    }
                }
            }
            NPCCD.PCCDChain(WMNode, out NodeGroups);



            // Translate solutions to its global node notation
        }
Пример #2
0
        // Verify all rules in a general product
        public static void CPCCDAllRules(List <List <int> > LinkToCut, double Alfa, List <List <int> > Modules, List <List <List <int> > > Communities, List <double> Modularity, List <double[, ]> SubGraphs, List <List <ComponentStruct> > SubVerticeMs,
                                         List <int[, ]> SubRelativeMs, double[] SizeLimit, int[] CFTypeCode, int[] MaterialList, out double[,] WMNode, out List <List <int> > TroubleNodeList, out List <int> TroubleCode, out List <List <int> > NodeGroups)
        {
            int NumOfLinks = LinkToCut.Count;
            int NumOfModules = Communities.Count;
            int NumOfNodes = 0;
            int ModuleID = 0;
            int NodeID1, NodeID2;

            for (int i = 0; i < Modules.Count; i++)
            {
                NumOfNodes += Modules[i].Count;
            }
            double[,] WMNode1 = new double[NumOfNodes, NumOfNodes];
            //Array.Copy(WeightMatrix, WMNode1, NumOfNode * NumOfNode);
            List <List <int> > TroubleNodeList2 = new List <List <int> >();
            List <int>         TroubleCode2 = new List <int>();

            for (int i = 0; i < NumOfLinks; i++)
            {
                TroubleNodeList2.Add(LinkToCut[i].ToList());
                TroubleCode2.Add(CFTypeCode[2]);
                //WMNode1[LinkToCut[i].ElementAt(0) - 1, LinkToCut[i].ElementAt(1) - 1] = 0;
                // WMNode1[LinkToCut[i].ElementAt(1) - 1, LinkToCut[i].ElementAt(0) - 1] = 0;
                /// Modify the links within the corresponding SubGraphs
                // find module ID first
                ModuleID           = NPCCD.PCCDFindRow(Modules, LinkToCut[i].ToList());
                double[,] T_Matrix = new double[Modules[ModuleID].Count, Modules[ModuleID].Count];
                Array.Copy(SubGraphs[ModuleID], T_Matrix, Modules[ModuleID].Count * Modules[ModuleID].Count);
                // find the index of nodes in the specific module
                NodeID1 = FindNodeIndex(Modules[ModuleID], LinkToCut[i].ElementAt(0));
                NodeID2 = FindNodeIndex(Modules[ModuleID], LinkToCut[i].ElementAt(1));
                T_Matrix[NodeID1, NodeID2] = 0;
                T_Matrix[NodeID2, NodeID1] = 0;
                SubGraphs[ModuleID]        = T_Matrix;
            }
            CPCCDAllRules_R3(Alfa, Modules, Communities, Modularity, SubGraphs, SubVerticeMs, SubRelativeMs, SizeLimit, CFTypeCode, MaterialList, out WMNode, out TroubleNodeList, out TroubleCode, out NodeGroups);
            TroubleNodeList.AddRange(TroubleNodeList2.ToList());
            TroubleCode.AddRange(TroubleCode2.ToList());
        }
Пример #3
0
        // verify all rules except R3 in each modules
        public static void MPCCDAllRules_R3(List <List <int> > Modules, double[,] WeightMatrix, List <ComponentStruct> VerticeMatrix, int[,] RelativeMotionMatrix, double[] SizeLimit, int[] CFTypeCode, int[] MaterialList,
                                            out double[,] WMNode, out List <List <int> > TroubleNodeList, out List <int> TroubleCode, out List <List <int> > NodeGroups)
        {
            int NumOfModules = Modules.Count;
            int NumOfNode    = WeightMatrix.GetLength(0);

            double[,] WMIntraModules = new double[NumOfNode, NumOfNode];
            List <double[, ]> SubGraphs = new List <double[, ]>();
            List <List <ComponentStruct> > SubVerticeMs = new List <List <ComponentStruct> >();
            List <int[, ]> SubRelativeMs = new List <int[, ]>();

            WMNode = new double[NumOfNode, NumOfNode];

            TroubleNodeList   = new List <List <int> >();
            TroubleCode       = new List <int>();
            NodeGroups        = new List <List <int> >();
            double[,] WMNode1 = new double[NumOfNode, NumOfNode];

            double[,] WMNode2, WMNode3;
            List <int>         TroubleCode1, TroubleCode2;
            List <List <int> > TroubleNodeList1, TroubleNodeList2;
            List <List <int> > T_TroubleNodeList = new List <List <int> >();
            List <int>         T_TroubleCode     = new List <int>();
            List <List <int> > T_NodeGroups      = new List <List <int> >();
            List <List <int> > GlobalTroubleNodeList;
            List <int>         GlobalTroubleCode;

            double[,] WMInterModule;
            // List<int> Module = new List<int>();

            //  MPCCDGenerateModule(NumOfNode, out Module);

            MPCCDSubGraph(Modules, WeightMatrix, VerticeMatrix, RelativeMotionMatrix, out WMIntraModules, out SubGraphs, out SubVerticeMs, out SubRelativeMs);
            MPCCDExtractInterM(WeightMatrix, Modules, out WMInterModule);  // extract inter module graph

            for (int i = 0; i < NumOfModules; i++)
            {
                double[,] T_WMNode = new double[Modules[i].Count, Modules[i].Count];
                NPCCD.NPCCDAllRules_R3(SubGraphs[i], SubVerticeMs[i], SizeLimit, MaterialList, SubRelativeMs[i], CFTypeCode, out T_WMNode, out T_TroubleNodeList, out T_TroubleCode, out T_NodeGroups);
                MPCCDTransLocalToGlobal(Modules[i], T_TroubleNodeList, T_TroubleCode, T_NodeGroups, out GlobalTroubleNodeList, out GlobalTroubleCode);
                TroubleNodeList.AddRange(GlobalTroubleNodeList.ToList());
                TroubleCode.AddRange(GlobalTroubleCode.ToList());
                // translate the surviving submodules to a whole global groph
                for (int j = 0; j < T_WMNode.GetLength(0); j++)
                {
                    for (int k = 0; k < T_WMNode.GetLength(0); k++)
                    {
                        if (T_WMNode[j, k] != 0)
                        {
                            WMNode1[Modules[i].ElementAt(j) - 1, Modules[i].ElementAt(k) - 1] = T_WMNode[j, k];
                            WMNode1[Modules[i].ElementAt(k) - 1, Modules[i].ElementAt(j) - 1] = T_WMNode[k, j];
                        }
                    }
                }
            }
            // Print.PrintList(TroubleNodeList);
            // Print.PrintMatrix(WMNode1);
            // verify R1-7 EXCEPT R5, R3 on inter-module graph
            // NPCCD.NPCCDAllRules_R3R5(WMInterModule, VerticeMatrix, SizeLimit, MaterialList, RelativeMotionMatrix, CFTypeCode, out WMNode2, out TroubleNodeList1, out TroubleCode1);

            NPCCD.PCCDNodePair(WMInterModule, VerticeMatrix, RelativeMotionMatrix, SizeLimit, CFTypeCode, out WMNode2, out TroubleNodeList1, out TroubleCode1);
            //Print.PrintList(TroubleNodeList1);
            // Print.PrintMatrix(WMNode2);
            MPCCDCombineGraph(WMNode1, WMNode2, out WMNode3);

            //NPCCD.NPCCDAllRules_R3(WMNode3, VerticeMatrix, SizeLimit, MaterialList, RelativeMotionMatrix, CFTypeCode, out WMNode, out TroubleNodeList2, out TroubleCode2, out NodeGroups);
            NPCCD.PCCDNodeGroup(WMNode3, VerticeMatrix, SizeLimit, CFTypeCode, out WMNode, out TroubleNodeList2, out TroubleCode2);
            NPCCD.PCCDChain(WMNode, out NodeGroups);
            TroubleNodeList.AddRange(TroubleNodeList1.ToList());
            TroubleNodeList.AddRange(TroubleNodeList2.ToList());
            TroubleCode.AddRange(TroubleCode1.ToList());
            TroubleCode.AddRange(TroubleCode2.ToList());
        }