• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# AdjacencyGraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FindAllPatterns

        /// <summary>
        /// Przerabia graf na string z odnalezionymi paternami
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        public string FindAllPatterns(AdjacencyGraph<Node, Edge<Node>> g)
        {
            bool nodesStillInGraph = true;
            while (nodesStillInGraph)
            {
                var decisionNodes = g.Vertices.Where(x => x.Type == NodeType.DecisionNode).ToList();
                var forkNodes = g.Vertices.Where(x => x.Type == NodeType.ForkNode).ToList();
                if (decisionNodes.Count == 0 && forkNodes.Count == 0)
                {
                    nodesStillInGraph = false;
                    continue;
                }
                g = FindLoopPattern(g);
                g = FindSeqPattern(g);

                g = FindDecisionPattern(g);
                g = FindSeqPattern(g);

                g = FindParPattern(g);
                g = FindSeqPattern(g);
            }

            if (g.Vertices.Count() == 3 && g.Edges.Count() == 2)
            {
                var start = g.Vertices.Where(x => x.Type == NodeType.InitalNode).ToList().FirstOrDefault();
                var end = g.Vertices.Where(x => x.Type == NodeType.ActivityFinalNode).ToList().FirstOrDefault();
                var body = g.Vertices.Where(x => x != start && x != end).ToList().FirstOrDefault();
                return "seqseq(" + start.Name + "," + body.Name + "," + end.Name + ")";
            }
            return "ERROR";
        }
开发者ID:jkubisiowski,项目名称:Generator,代码行数:36,代码来源:PatternFinder.cs


示例2: Simple

 public void Simple()
 {
     AdjacencyGraph<string, Edge<string>> g = new AdjacencyGraph<string, Edge<string>>();
     GraphFactory.Simple(g);
     this.Compute(g);
     this.ComputeCriticalPath(g);
 }
开发者ID:buptkang,项目名称:QuickGraph,代码行数:7,代码来源:DagShortestPathAlgorithmTest.cs


示例3: createGraphWizDotFile

    	//DC this version was using the old QuickGraph MarkedEdge
        public static void createGraphWizDotFile(AdjacencyGraph<String, TaggedEdge<String, String>> gGraphWizToPopulate,
                                                 TreeNode tnTreeNode, bool bOrder, bool bFilterName, bool bFilterClass,
                                                 int iFilterClassLevel)
        {
            if (bFilterClass)
                tnTreeNode.Text = FilteredSignature.filterName(tnTreeNode.Text, false, false, true, 0, true, true,
                                                               iFilterClassLevel);
            TaggedEdge<String, string> meTemp;
            if (gGraphWizToPopulate.ContainsVertex(tnTreeNode.Text))
            {
            }
            else
                gGraphWizToPopulate.AddVertex(tnTreeNode.Text);

            foreach (TreeNode tnChild in tnTreeNode.Nodes)
            {
                if (bFilterClass)
                    tnChild.Text = FilteredSignature.filterName(tnChild.Text, false, false, true, 0, true, true,
                                                                iFilterClassLevel);
                createGraphWizDotFile(gGraphWizToPopulate, tnChild, bOrder, bFilterName, bFilterClass, iFilterClassLevel);
                if (bOrder)
                {
                    if (false == gGraphWizToPopulate.TryGetEdge(tnTreeNode.Text, tnChild.Text, out meTemp))
                        gGraphWizToPopulate.AddEdge(new TaggedEdge<String, string>(tnTreeNode.Text, tnChild.Text,
                                                                                   "marker"));
                }
                else if (false == gGraphWizToPopulate.TryGetEdge(tnChild.Text, tnTreeNode.Text, out meTemp))
                    gGraphWizToPopulate.AddEdge(new TaggedEdge<String, string>(tnChild.Text, tnTreeNode.Text, "marker"));

                //gGraphToPopulate.AddEdge(tnTreeNode.Text, tnChild.Text);
                //    gGraphToPopulate.AddEdge(Analysis_CallFlow.display.filterName(tnChild.Text, false, false, false), Analysis_CallFlow.display.filterName(tnTreeNode.Text, false, false, false));
                //else
            }
        }
开发者ID:pusp,项目名称:o2platform,代码行数:35,代码来源:O2Graph.cs


示例4: BuildReferencesGraph

		private static AdjacencyGraph<string, Edge<string>> BuildReferencesGraph(out Dictionary<string, string> servers)
		{
			servers = new Dictionary<string, string>();

			var graph = new AdjacencyGraph<string, Edge<string>>();
			foreach (var serverName in Args.ServerNames.Split('|'))
			{
				var projectsPath = Paths.ProjectsFolder(serverName);
				foreach (var projectFolder in Directory.GetDirectories(projectsPath))
				{
					var projectName = Path.GetFileName(projectFolder);
					var referencesFolder = Path.Combine(projectFolder, Args.ReferencesFolder);

					servers.Add(projectName, serverName);

					if (!Directory.Exists(referencesFolder))
						continue;

					var referenceFiles = Directory.GetFiles(referencesFolder).Select(Path.GetFileNameWithoutExtension);

					graph.AddVerticesAndEdgeRange(referenceFiles.Select(referenceName => new Edge<string>(referenceName, projectName)));
				}
			}

			return graph;
		}
开发者ID:shuruev,项目名称:CCNet.Extensions,代码行数:26,代码来源:Program.cs


示例5: ParkingMap

 public ParkingMap(string name, int width, int height)
 {
     Name = name;
     Width = width;
     Height = height;
     Graph = new AdjacencyGraph<Vertex, Edge<Vertex>>();
 }
开发者ID:neoxack,项目名称:Parking,代码行数:7,代码来源:ParkingMap.cs


示例6: BuildDependencyGraph

        public static AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>> BuildDependencyGraph(Type viewModelType)
        {
            var directDependencies = ViewModelConventions.GetViewModelProperties(viewModelType).ToDictionary(p => p, GetDirectDependentProperties);

            var graph = new AdjacencyGraph<PropertyInfo, STaggedEdge<PropertyInfo, string>>();

            foreach (var directDependency in directDependencies)
            {
                var property = directDependency.Key;
                graph.AddVertex(property);

                foreach (var dependentProperty in directDependency.Value)
                {
                    var sub = dependentProperty.SubPath;
                    var propertyType = property.PropertyType;
                    if (GetCollectionType(propertyType) != null) propertyType = GetCollectionType(propertyType);

                    if (String.IsNullOrEmpty(sub) && ViewModelConventions.IsViewModel(propertyType))
                        sub = "*";

                    graph.AddEdge(new STaggedEdge<PropertyInfo, string>(property, dependentProperty.Property, sub));
                }
            }

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


示例7: QGPathFinder

        public QGPathFinder(Status status, MainForm parent)
        {
            m_parent = parent;
            m_status = status;

            graph = new AdjacencyGraph<string, Edge<string>>(true);
            edgeCost = new Dictionary<Edge<string>, double>(graph.EdgeCount);
            this.fp = m_status.floorPlan;
            if (this.m_status.position != null)
            {
                startPoint = this.m_status.position.location.X + "_" + this.m_status.position.location.Y;
                m_parent.PostMessage("start: " + startPoint);
            }
            else
            {
                startPoint = "4_4";
            }
            if (this.m_status.endPoint!= null)
            {
                targetPoint = this.m_status.endPoint.X + "_" + this.m_status.endPoint.Y;
                m_parent.PostMessage("end: " + targetPoint);
            }
            else
            {
                targetPoint = "4_6";
            }

            buildGraph();
        }
开发者ID:tkram01,项目名称:see3po,代码行数:29,代码来源:QGPathFinder.cs


示例8: CheckPredecessorLineGraph

        public void CheckPredecessorLineGraph()
        {
            AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(1);
            g.AddVertex(2);
            g.AddVertex(3);

            Edge<int> e12 = new Edge<int>(1, 2); g.AddEdge(e12);
            Edge<int> e23 = new Edge<int>(2, 3); g.AddEdge(e23);

            Dictionary<Edge<int>, double> weights =
                DijkstraShortestPathAlgorithm<int, Edge<int>>.UnaryWeightsFromEdgeList(g);
            DijkstraShortestPathAlgorithm<int, Edge<int>> dij = new DijkstraShortestPathAlgorithm<int, Edge<int>>(g, weights);
            VertexPredecessorRecorderObserver<int, Edge<int>> vis = new VertexPredecessorRecorderObserver<int, Edge<int>>();
            vis.Attach(dij);
            dij.Compute(1);

            IList<Edge<int>> col = vis.Path(2);
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(e12, col[0]);

            col = vis.Path(3);
            Assert.AreEqual(2, col.Count);
            Assert.AreEqual(e12, col[0]);
            Assert.AreEqual(e23, col[1]);
        }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:26,代码来源:DijkstraShortestPathAlgorithmTest.cs


示例9: CheckPredecessorDoubleLineGraph

        public void CheckPredecessorDoubleLineGraph()
        {
            AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(1);
            g.AddVertex(2);
            g.AddVertex(3);

            Edge<int> e12 = new Edge<int>(1, 2); g.AddEdge(e12);
            Edge<int> e23 = new Edge<int>(2, 3); g.AddEdge(e23);
            Edge<int> e13 = new Edge<int>(1, 3); g.AddEdge(e13);

            var dij = new DijkstraShortestPathAlgorithm<int, Edge<int>>(g, e => 1);
            var vis = new VertexPredecessorRecorderObserver<int, Edge<int>>();
            using(vis.Attach(dij))
                dij.Compute(1);

            IEnumerable<Edge<int>> path;
            Assert.IsTrue(vis.TryGetPath(2, out path));
            var col = path.ToList();
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(e12, col[0]);

            Assert.IsTrue(vis.TryGetPath(3, out path));
            col = path.ToList();
            Assert.AreEqual(1, col.Count);
            Assert.AreEqual(e13, col[0]);
        }
开发者ID:GovorukhaOksana,项目名称:QuickGraph,代码行数:27,代码来源:DijkstraShortestPathAlgorithmTestOld.cs


示例10: FileDependency

 public void FileDependency()
 {
     AdjacencyGraph<string, Edge<string>> g = new AdjacencyGraph<string, Edge<string>>();
     GraphFactory.FileDependency(g);
     this.Compute(g);
     this.ComputeCriticalPath(g);
 }
开发者ID:buptkang,项目名称:QuickGraph,代码行数:7,代码来源:DagShortestPathAlgorithmTest.cs


示例11: GenerateDotFile

        public void GenerateDotFile()
        {
            var graph = new AdjacencyGraph<string, TaggedEdge<string, string>>();

            for (int i = 0; i < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); i++)
            {
                graph.AddVertex(String.Format("{0}", i));
            }
            for (int i = 0; i < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); i++)
            {
                for (int j = 0; j < Math.Sqrt(Convert.ToDouble(m_Matrix.Length)); j++)
                {
                    if ((m_Matrix[i, j] == true) & (i < j))
                    {
                        graph.AddEdge(new TaggedEdge<string, string>(String.Format("{0}", i), String.Format("{0}", j), String.Format("{0}", i)));
                    }
                }
            }

            var graphViz = new GraphvizAlgorithm<string, TaggedEdge<string, string>>(graph, @".\", QuickGraph.Graphviz.Dot.GraphvizImageType.Png);
            graphViz.FormatVertex += (sender, e) =>
            {
                e.VertexFormatter.Shape = QuickGraph.Graphviz.Dot.GraphvizVertexShape.Circle;
            };

            graphViz.FormatEdge += (sender, e) =>
            {
                e.EdgeFormatter.Dir = QuickGraph.Graphviz.Dot.GraphvizEdgeDirection.None;
            };

            graphViz.Generate(new FileDotEngine(), m_Name);
        }
开发者ID:Butyava,项目名称:DemoGraphWPF,代码行数:32,代码来源:Graph.cs


示例12: Removing_Explicit_Edges_2

		public void Removing_Explicit_Edges_2()
		{
			var graph = new AdjacencyGraph<int, Edge<int>>();
			graph.AddVertex(1);
			graph.AddVertex(2);
			graph.AddVertex(3);
			graph.AddVertex(4);
			graph.AddVertex(5);
			graph.AddVertex(6);
			graph.AddVertex(7);
			graph.AddEdge(new Edge<int>(1, 3));
			graph.AddEdge(new Edge<int>(1, 4));
			graph.AddEdge(new Edge<int>(1, 6));
			graph.AddEdge(new Edge<int>(3, 6));
			graph.AddEdge(new Edge<int>(4, 6));
			graph.AddEdge(new Edge<int>(2, 4));
			graph.AddEdge(new Edge<int>(2, 5));
			graph.AddEdge(new Edge<int>(2, 7));
			graph.AddEdge(new Edge<int>(4, 7));
			graph.AddEdge(new Edge<int>(5, 7));

			GraphHelper.RemoveExplicitEdges(graph);

			Assert.AreEqual(8, graph.EdgeCount);
			Assert.IsTrue(graph.ContainsEdge(1, 3));
			Assert.IsTrue(graph.ContainsEdge(1, 4));
			Assert.IsTrue(graph.ContainsEdge(2, 4));
			Assert.IsTrue(graph.ContainsEdge(2, 5));
			Assert.IsTrue(graph.ContainsEdge(3, 6));
			Assert.IsTrue(graph.ContainsEdge(4, 6));
			Assert.IsTrue(graph.ContainsEdge(4, 7));
			Assert.IsTrue(graph.ContainsEdge(5, 7));
		}
开发者ID:penartur,项目名称:CCNet.Extensions,代码行数:33,代码来源:GraphHelperTest.cs


示例13: QGPathFinder

        public QGPathFinder(FloorPlan floorPlan)
        {
            this.messages += "- Checking Floor Plan...\n";
            graph = new AdjacencyGraph<string, Edge<string>>(true);
            edgeCost = new Dictionary<Edge<string>, double>(graph.EdgeCount);
            this.fp = floorPlan;

            if (this.fp.getStartTile() != null)
            {
                this.messages += "    Start Point is OK...\n";
                startPoint = this.fp.getStartTile().Position.X + "_" + this.fp.getStartTile().Position.Y;
            }
            else
            {
                this.messages += "    Start Point is not valid...\n";
                startPoint = "4_4";
            }

            if (this.fp.getTargetTile() != null)
            {
                this.messages += "    Target Point is OK...\n";
                targetPoint = this.fp.getTargetTile().Position.X + "_" + this.fp.getTargetTile().Position.Y;
            }
            else
            {
                this.messages += "    Target Point is not valid...\n";
                targetPoint = "4_6";
            }

            buildGraph();
        }
开发者ID:tkram01,项目名称:see3po,代码行数:31,代码来源:QGPathFinder.cs


示例14: RouteFinder

 public RouteFinder(IGameDataProvider gameDataProvider)
 {
     provider = gameDataProvider;
     logger = LogManager.GetCurrentClassLogger();
     graph = new AdjacencyGraph<StarSystem, Edge<StarSystem>>();
     weights = new Dictionary<Edge<StarSystem>, double>();
 }
开发者ID:sidrus,项目名称:EDTrader,代码行数:7,代码来源:RouteFinder.cs


示例15: Render

        public override void Render(Context context, TextWriter result)
        {
            // init modules context
            ModulesContext modules = DotLiquidModules.ContextExtractor.GetOrAddModulesContext(context);
            
            // allow module name to be supplied as a variable, makes sense when you supply modules in the Model
            object evalName = context[_moduleName];
            string modName = evalName != null ? Convert.ToString(evalName) : _moduleName;
            
            // remember modules that were already loaded
            Dictionary<string, bool> alreadyLoaded = new Dictionary<string, bool>();
            foreach (string moduleName in modules.ModuleIndex.Keys)
            {
                alreadyLoaded[moduleName] = true;
            }

            // add module to context, get its dependencies in graph
            AdjacencyGraph<Module, Edge<Module>> dependencyGraph = new AdjacencyGraph<Module, Edge<Module>>(true);
            AddModuleToContextByName(modName, modules, context, dependencyGraph);

            // add dependency tree into context's dependency list
            foreach (Module module in dependencyGraph.TopologicalSort())
            {
                if (!alreadyLoaded.ContainsKey(module.ModuleName))
                {
                    modules.DependencyOrder.Add(module);
                }
            }
        }
开发者ID:gmanny,项目名称:DotLiquid.Modules,代码行数:29,代码来源:UseModule.cs


示例16: CreateGraphOfPipeSystem

        private static IVertexAndEdgeListGraph<PipeGraphVertex, Edge<PipeGraphVertex>> CreateGraphOfPipeSystem(PipeGraphVertex firstVertex)
        {
            var graph = new AdjacencyGraph<PipeGraphVertex, Edge<PipeGraphVertex>>(false);
            var verticesSeen = new HashSet<PipeGraphVertex>();
            var verticesToCheck = new Stack<PipeGraphVertex>();
            verticesToCheck.Push(firstVertex);

            while (verticesToCheck.Any())
            {
                var vertexToCheck = verticesToCheck.Pop();
                if (verticesSeen.Contains(vertexToCheck)) continue;

                var sendsTo = GetVerticesYouSendMessagesTo(vertexToCheck);
                var receivesFrom = GetVerticesYouReceiveMessagesFrom(vertexToCheck);

                foreach (var vertex in sendsTo) verticesToCheck.Push(vertex);
                foreach (var vertex in receivesFrom) verticesToCheck.Push(vertex);

                graph.AddVertex(vertexToCheck);

                graph.AddVerticesAndEdgeRange(sendsTo.Select(v => new Edge<PipeGraphVertex>(vertexToCheck, v)));
                graph.AddVerticesAndEdgeRange(receivesFrom.Select(v => new Edge<PipeGraphVertex>(v, vertexToCheck)));

                verticesSeen.Add(vertexToCheck);
            }

            return graph;
        }
开发者ID:michaelbradley91,项目名称:Pipes,代码行数:28,代码来源:PipeExtensions.cs


示例17: CreateAdjacencyGraph

        static AdjacencyGraph<Vertex, Edge<Vertex>> CreateAdjacencyGraph(StateMachineGraph data)
        {
            var graph = new AdjacencyGraph<Vertex, Edge<Vertex>>();

            graph.AddVertexRange(data.Vertices);
            graph.AddEdgeRange(data.Edges.Select(x => new Edge<Vertex>(x.From, x.To)));
            return graph;
        }
开发者ID:StuartBaker65,项目名称:Automatonymous,代码行数:8,代码来源:StateMachineGraphGenerator.cs


示例18: IsolatedVertex

        public void IsolatedVertex()
        {
            AdjacencyGraph<int, Edge<int>> g = new AdjacencyGraph<int, Edge<int>>(true);
            g.AddVertex(0);

            target = new CyclePoppingRandomTreeAlgorithm<int, Edge<int>>(g);
            target.RandomTree();
        }
开发者ID:sayedjalilhassan,项目名称:LearningPlatform,代码行数:8,代码来源:CyclePoppingRandomTreeAlgorithmTest.cs


示例19: PathFinder

        /// <summary>
        /// Initializes a new instance of the <see cref="GraphBuilder2"/> class.
        /// </summary>
        /// <param name="bidirectional">
        /// Specify if the graph must be build using both edges directions.
        /// </param>
        public PathFinder(bool bidirectional)
        {
            this.bidirectional = bidirectional;

            factory = null;
            strings = new List<ILineString>();
            graph   = new AdjacencyGraph<Coordinate, IEdge<Coordinate>>(true);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:14,代码来源:PathFinder.cs


示例20: EmptyGraph

 public void EmptyGraph()
 {
     IVertexListGraph<string, Edge<string>> g = new AdjacencyGraph<string, Edge<string>>(true);
     StronglyConnectedComponentsAlgorithm<string, Edge<String>> strong = new StronglyConnectedComponentsAlgorithm<string, Edge<String>>(g);
     strong.Compute();
     Assert.AreEqual(0, strong.ComponentCount);
     checkStrong(strong);
 }
开发者ID:buptkang,项目名称:QuickGraph,代码行数:8,代码来源:StronglyConnectedComponentsAlgorithmTest.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Admin类代码示例发布时间:2022-05-24
下一篇:
C# AdhocWorkspace类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap