当前位置: 首页>>代码示例>>C#>>正文


C# AdjacencyGraph.RemoveVertexIf方法代码示例

本文整理汇总了C#中AdjacencyGraph.RemoveVertexIf方法的典型用法代码示例。如果您正苦于以下问题:C# AdjacencyGraph.RemoveVertexIf方法的具体用法?C# AdjacencyGraph.RemoveVertexIf怎么用?C# AdjacencyGraph.RemoveVertexIf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AdjacencyGraph的用法示例。


在下文中一共展示了AdjacencyGraph.RemoveVertexIf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveIrrelevantBranches

 private void RemoveIrrelevantBranches(AdjacencyGraph<IBuilder, EquatableEdge<IBuilder>> graph, IBuilder rootBuilder)
 {
     var bfs = new BreadthFirstSearchAlgorithm<IBuilder, EquatableEdge<IBuilder>>(graph);
     var toKeep = new HashSet<EquatableEdge<IBuilder>>();
     var buildersToKeep = new HashSet<IBuilder>();
     bfs.TreeEdge += e => toKeep.Add(e);
     bfs.NonTreeEdge += e => toKeep.Add(e);
     bfs.DiscoverVertex += b => buildersToKeep.Add(b);
     bfs.Compute(rootBuilder);
     graph.RemoveEdgeIf(edge => !toKeep.Contains(edge));
     graph.RemoveVertexIf(vertex => !buildersToKeep.Contains(vertex));
 }
开发者ID:vigoo,项目名称:bari,代码行数:12,代码来源:BuildContext.cs

示例2: RemoveIrrelevantBranches

 private void RemoveIrrelevantBranches(AdjacencyGraph<IBuilder, EquatableEdge<IBuilder>> graph, IBuilder rootBuilder)
 {
     var bfs = new BreadthFirstSearchAlgorithm<IBuilder, EquatableEdge<IBuilder>>(graph);
     bfs.Compute(rootBuilder);
     var toKeep = new HashSet<IBuilder>(bfs.VisitedGraph.Vertices);
     graph.RemoveVertexIf(v => !toKeep.Contains(v));
 }
开发者ID:zvrana,项目名称:bari,代码行数:7,代码来源:BuildContext.cs

示例3: BuildDependencyGraph

        public static AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>> BuildDependencyGraph(IEnumerable<Type> viewModelTypes)
        {
            var graph = new AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>>();

            foreach (var dependencyGraphWithinViewModel in viewModelTypes.Select(BuildDependencyGraph))
            {
                dependencyGraphWithinViewModel.Vertices.ForEach(v => graph.AddVertex(v));
                dependencyGraphWithinViewModel.Edges.ForEach(e => graph.AddEdge(e));
            }

            while (graph.Edges.Any(e => !String.IsNullOrEmpty(e.Tag)))
            {
                var edge = graph.Edges.First(e => !String.IsNullOrEmpty(e.Tag));

                var index = edge.Tag.IndexOf(".");
                var path = index < 0 ? edge.Tag : edge.Tag.Substring(0, index);
                var rest = index < 0 ? null : edge.Tag.Substring(index + 1);

                var propertyType = edge.Source.PropertyType;
                if (GetCollectionType(propertyType) != null) propertyType = GetCollectionType(propertyType);

                if (path != "*")
                {
                    var property = ViewModelConventions.GetViewModelProperties(propertyType).FirstOrDefault(p => p.Name == path);
                    if (property != null)
                    {
                        graph.AddEdge(new STaggedEdge<PropertyInfo, string>(property, edge.Target, rest));
                    }
                    else
                    {
                        ViewModelConventions.Log.Warn(String.Format("Could not resolve '{0}' on '{1}'.", path, propertyType));
                    }
                }
                else
                {
                    var properties = ViewModelConventions.GetViewModelProperties(propertyType).ToList();
                    properties.ForEach(p => graph.AddEdge(new STaggedEdge<PropertyInfo, string>(p, edge.Target, rest)));
                }

                graph.RemoveEdge(edge);
            }

            var edges = graph.Edges.ToArray();
            graph.RemoveVertexIf(v => !edges.Any(e => e.Source == v || e.Target == v));

            return graph;
        }
开发者ID:oliverhanappi,项目名称:notifui,代码行数:47,代码来源:PropertyDependencies.cs


注:本文中的AdjacencyGraph.RemoveVertexIf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。