示例#1
0
        private static GeneralCluster ReturnClusterAndPartition(LightWeightGraph healthy,
                                                                LightWeightGraph infected, int healthyClusters, int infectedClusters, String healthyfile,
                                                                String infectedfile)
        {
            String         workingDir = Directory.GetCurrentDirectory();
            GeneralCluster cluster    = new GeneralCluster();

            cluster.Int0.Cluster =
                new HIntegrityClust(healthy, healthyClusters + 1, false, 1, 0, false, false);
            cluster.Int0.Partition = cluster.Int0.Cluster.GetPartition();
            cluster.Int0.Partition.SavePartition($"{workingDir}/Data/{healthyfile}_INT.cluster", $"{workingDir}/{healthyfile}.graph");
            cluster.Int1.Cluster =
                new HIntegrityClust(infected, infectedClusters + 1, false, 1, 0, false, false);
            cluster.Int1.Partition = cluster.Int1.Cluster.GetPartition();
            cluster.Int1.Partition.SavePartition($"{workingDir}/Data/{infectedfile}_INT.cluster", $"{workingDir}/{infectedfile}.graph");
            cluster.HealthyIntCount  = new int[cluster.Int0.Partition.DataCount];
            cluster.InfectedIntCount = new int[cluster.Int1.Partition.DataCount];
            cluster.Ten0.Cluster     =
                new HTenacityClust(healthy, healthyClusters + 1, false, 1, 0, false, false);
            cluster.Ten0.Partition = cluster.Ten0.Cluster.GetPartition();
            cluster.Ten0.Partition.SavePartition($"{workingDir}/Data/{healthyfile}_TEN.cluster", $"{workingDir}/{healthyfile}.graph");
            cluster.Ten1.Cluster =
                new HTenacityClust(infected, infectedClusters + 1, false, 1, 0, false, false);
            cluster.Ten1.Partition = cluster.Ten1.Cluster.GetPartition();
            cluster.Ten1.Partition.SavePartition($"{workingDir}/Data/{infectedfile}_TEN.cluster", $"{workingDir}/{infectedfile}.graph");
            cluster.HealthyTenCount  = new int[cluster.Ten0.Partition.DataCount];
            cluster.InfectedTenCount = new int[cluster.Ten1.Partition.DataCount];
            cluster.Vat0.Cluster     = new HVATClust(healthy, healthyClusters + 1, false, 1, 0, false, false);
            cluster.Vat0.Partition   = cluster.Vat0.Cluster.GetPartition();
            cluster.Vat0.Partition.SavePartition($"{workingDir}/Data/{infectedfile}_VAT.cluster", $"{workingDir}/{infectedfile}.graph");
            cluster.Vat1.Cluster =
                new HVATClust(infected, infectedClusters + 1, false, 1, 0, false, false);
            cluster.Vat1.Partition = cluster.Vat1.Cluster.GetPartition();
            cluster.Vat1.Partition.SavePartition($"{workingDir}/Data/{infectedfile}_VAT.cluster", $"{workingDir}/{infectedfile}.graph");
            cluster.HealthyVatCount  = new int[cluster.Vat0.Partition.DataCount];
            cluster.InfectedVatCount = new int[cluster.Vat1.Partition.DataCount];

            return(cluster);
        }
示例#2
0
        private static List <DataOutStruct> ConstructList(string args, LightWeightGraph healthy,
                                                          LightWeightGraph infected, String healthyfile, String infectedfile, int healthyClusters,
                                                          int infectedClusters)
        {
            List <List <DataOutStruct> > outList = new List <List <DataOutStruct> >();
            List <DataOutStruct>         dataOut = new List <DataOutStruct>();

            if (Enum.TryParse <ClusterType>(args, ignoreCase: true, result: out var userOut))
            {
                GeneralCluster cluster = ReturnClusterAndPartition(healthy, infected, healthyClusters, infectedClusters,
                                                                   healthyfile, infectedfile);
                List <DataOutStruct> d1;
                List <DataOutStruct> d2;
                List <DataOutStruct> d3;
                switch (userOut)
                {
                case ClusterType.G1I:
                    dataOut = G1(GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                                  cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int,
                                                  outList));
                    break;

                case ClusterType.G1T:
                    dataOut = G1(GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition,
                                                  cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten,
                                                  outList));
                    break;

                case ClusterType.G1V:
                    dataOut = G1(GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                                  cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat,
                                                  outList));
                    break;

                case ClusterType.G2I:
                    dataOut = G2(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    break;

                case ClusterType.G2T:
                    dataOut = G2(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition, cluster.HealthyTenCount,
                                         cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten, outList),
                        cluster.Ten0.Partition, cluster.Ten1.Partition, OutType.Ten);
                    break;

                case ClusterType.G2V:
                    dataOut = G2(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition, cluster.HealthyVatCount,
                                         cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat, outList),
                        cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    break;

                case ClusterType.G3I:
                    dataOut = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    break;

                case ClusterType.G3T:
                    dataOut = G3(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition, cluster.HealthyTenCount,
                                         cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten, outList),
                        cluster.Ten0.Partition, cluster.Ten1.Partition, OutType.Ten);
                    break;

                case ClusterType.G3V:
                    dataOut = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    break;

                case ClusterType.G4I:
                    dataOut = G4(GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                                  cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int,
                                                  outList));
                    break;

                case ClusterType.G4T:
                    dataOut = G4(GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition,
                                                  cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten,
                                                  outList));
                    break;

                case ClusterType.G4V:
                    dataOut = G4(GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                                  cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat,
                                                  outList));
                    break;

                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //                                            start of G13 - G25                                               //
                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                case ClusterType.G13:
                    d1 = G1(GroupInitializer(cluster.Vat0.Partition,
                                             cluster.Vat1.Partition, cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile,
                                             infectedfile, OutType.Vat, outList));
                    d2 = G2(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    d3 = G2(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition, cluster.HealthyVatCount,
                                         cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat, outList),
                        cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G14:
                    d1 = G1(GroupInitializer(cluster.Vat0.Partition,
                                             cluster.Vat1.Partition, cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile,
                                             infectedfile, OutType.Vat, outList));
                    d2 = G2(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition, cluster.HealthyTenCount,
                                         cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten, outList),
                        cluster.Ten0.Partition, cluster.Ten1.Partition, OutType.Ten);
                    d3 = G2(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G15:
                    d1 = G1(GroupInitializer(cluster.Ten0.Partition,
                                             cluster.Ten0.Partition, cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile,
                                             infectedfile, OutType.Ten, outList));
                    d2 = G2(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition, cluster.HealthyTenCount,
                                         cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten, outList),
                        cluster.Ten0.Partition, cluster.Ten1.Partition, OutType.Ten);
                    d3 = G2(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G16:
                    d1 = G1(GroupInitializer(cluster.Int0.Partition,
                                             cluster.Int0.Partition, cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile,
                                             infectedfile, OutType.Int, outList));
                    d2 = G2(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition, cluster.HealthyIntCount,
                                         cluster.InfectedIntCount, healthyfile, infectedfile, OutType.Int, outList),
                        cluster.Int0.Partition, cluster.Int1.Partition, OutType.Int);
                    d3 = G2(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition, cluster.HealthyVatCount,
                                         cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat, outList),
                        cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G17:
                    d1 = G1(GroupInitializer(cluster.Vat0.Partition,
                                             cluster.Vat1.Partition, cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile,
                                             infectedfile, OutType.Vat, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G18:
                    d1 = G1(GroupInitializer(cluster.Int0.Partition,
                                             cluster.Int1.Partition, cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile,
                                             infectedfile, OutType.Int, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G19:
                    d1 = G1(GroupInitializer(cluster.Ten0.Partition,
                                             cluster.Ten1.Partition, cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile,
                                             infectedfile, OutType.Ten, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G20:
                    d1 = G1(GroupInitializer(cluster.Ten0.Partition,
                                             cluster.Ten1.Partition, cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile,
                                             infectedfile, OutType.Ten, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G21:
                    d1 = G4(GroupInitializer(cluster.Vat0.Partition,
                                             cluster.Vat1.Partition, cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile,
                                             infectedfile, OutType.Vat, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G22:
                    d1 = G4(GroupInitializer(cluster.Int0.Partition,
                                             cluster.Int1.Partition, cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile,
                                             infectedfile, OutType.Int, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G23:
                    d1 = G4(GroupInitializer(cluster.Ten0.Partition,
                                             cluster.Ten1.Partition, cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile,
                                             infectedfile, OutType.Ten, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Int0.Partition, cluster.Int1.Partition,
                                         cluster.HealthyIntCount, cluster.InfectedIntCount, healthyfile, infectedfile,
                                         OutType.Int, outList), cluster.Int0.Partition, cluster.Int1.Partition,
                        OutType.Int);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition,
                                         cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile, infectedfile,
                                         OutType.Vat, outList), cluster.Vat0.Partition, cluster.Vat1.Partition,
                        OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G24:
                    d1 = G4(GroupInitializer(cluster.Ten0.Partition,
                                             cluster.Ten1.Partition, cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile,
                                             infectedfile, OutType.Ten, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition,
                                         cluster.HealthyTenCount, cluster.InfectedTenCount, healthyfile, infectedfile,
                                         OutType.Ten, outList), cluster.Ten0.Partition, cluster.Ten1.Partition,
                        OutType.Ten);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition, cluster.HealthyVatCount,
                                         cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat, outList),
                        cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;

                case ClusterType.G25:
                    d1 = G4(GroupInitializer(cluster.Vat0.Partition,
                                             cluster.Vat1.Partition, cluster.HealthyVatCount, cluster.InfectedVatCount, healthyfile,
                                             infectedfile, OutType.Vat, outList));
                    d2 = G3(
                        GroupInitializer(cluster.Ten0.Partition, cluster.Ten1.Partition, cluster.HealthyTenCount,
                                         cluster.InfectedTenCount, healthyfile, infectedfile, OutType.Ten, outList),
                        cluster.Ten0.Partition, cluster.Ten1.Partition, OutType.Ten);
                    d3 = G3(
                        GroupInitializer(cluster.Vat0.Partition, cluster.Vat1.Partition, cluster.HealthyVatCount,
                                         cluster.InfectedVatCount, healthyfile, infectedfile, OutType.Vat, outList),
                        cluster.Vat0.Partition, cluster.Vat1.Partition, OutType.Vat);
                    dataOut = d1.Union(d2).Where(x => !d3.Contains(x)).OrderBy(x => x.Bacteria).Distinct().ToList();
                    break;
                }
            }

            return(dataOut);
        }