• C# 循环依赖,分片,聚类


     1   public static List<ProjectModel> While_ProjectRef(ProjectModel projectModel,SolutionModel solutionModel,
     2             List<ProjectModel> ProjectCrip)
     3         {
     4             List<ProjectModel> Self_Refs = new List<ProjectModel>();
     5             if(projectModel.Projectrefs.Count>0)
     6             {
     7                 foreach(var ProjectRef in projectModel.Projectrefs)
     8                 {
     9                     //对于每一个项目引用进行分析
    10                     foreach (var project in solutionModel.Projects)
    11                     {
    12                         //寻找项目引用的projecta
    13                         if (project.Name == ProjectRef.Name)
    14                         {
    15                             //如果已经被分析过了,那么就不再分析这个子引用
    16                             if (ProjectCrip.Contains(project))
    17                                 break;
    18                             ProjectCrip.Add(project);
    19                             Self_Refs.Add(project);
    20                             break;
    21                         }
    22                     }
    23                 }
    24                 foreach (var Project_ref in Self_Refs)
    25                 {
    26                     var child_project_ref=While_ProjectRef(Project_ref, solutionModel, ProjectCrip);
    27                     ProjectCrip = ProjectCrip.Union(child_project_ref).ToList();
    28                 }
    29             }
    30             return ProjectCrip;
    31         }
    32 
    33 
    34  static public void Main(string[] args)
    35         {
    36             SolutionModel solutionModel = new SolutionModel();
    37             ProjectModel A1 = new ProjectModel();
    38             A1.Name = "A1";
    39             ProjectModel A2 = new ProjectModel();
    40             A2.Name = "A2";
    41             ProjectModel A3 = new ProjectModel();
    42             A3.Name = "A3";
    43             //Model1: A1-》A2-》A3
    44             //A1.Projectrefs.Add(A2);
    45             //A2.Projectrefs.Add(A3);
    46             //Model2: A1-》A2-》A1
    47             //A1.Projectrefs.Add(A2);
    48             //A2.Projectrefs.Add(A1);
    49             //Model3: A1-》A2-》A3->A1
    50             //A1.Projectrefs.Add(A2);
    51             //A2.Projectrefs.Add(A3);
    52             //A2.Projectrefs.Add(A1);
    53 
    54             //Model4: A1-》A2-》A3->A1
    55             //        A1->A3->A1
    56             //A1.Projectrefs.Add(A2);
    57             //A2.Projectrefs.Add(A3);
    58             //A3.Projectrefs.Add(A1);
    59 
    60             //A1.Projectrefs.Add(A3);
    61             //A3.Projectrefs.Add(A1);
    62             //Model5: A1-》A1
    63             A1.Projectrefs.Add(A1);
    64 
    65 
    66             solutionModel.Projects.Add(A1);
    67             solutionModel.Projects.Add(A2);
    68             solutionModel.Projects.Add(A3);
    69 
    70             List<ProjectModel> result=new List<ProjectModel> ();
    71             result = While_ProjectRef(A1, solutionModel, result);
    72             if(!result.Contains(A1))
    73                 result.Add(A1);
    74             Console.ReadKey();
    75         }
  • 相关阅读:
    直接插入排序
    排序概述
    因为现在这个水平还用不到树和图,所有之后放弃树和图的学习,直接进入排序的学习,现在学到排序树的删除部分,还没学完删除
    检索树
    二叉树的构造
    dedecms 忘记后台密码
    php配置伪静态的方法
    thinkPHP 中去除URL中的index.php
    thinkphp 验证码的使用
    php MySQL数据库操作类源代码
  • 原文地址:https://www.cnblogs.com/smartisn/p/16164223.html
Copyright © 2020-2023  润新知