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


C# Graph.V方法代码示例

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


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

示例1: DepthFirstSearchTest

        public void DepthFirstSearchTest()
        {
            string[] graphEdges = new[] {
                "0 5",
                "2 4",
                "2 3",
                "1 2",
                "0 1",
                "3 4",
                "3 5",
                "0 2"};

            var graph = new Graph(6, 8, graphEdges);

            DepthFirstSearch search = new DepthFirstSearch(graph, 0);

            for (int v = 0; v < graph.V(); v++)
            {
                if (search.Marked(v))
                {
                    Console.WriteLine(v + " ");
                }
            }

            Console.WriteLine();
            bool isCohesion = true;
            if (search.Count() != graph.V())
            {
                isCohesion = false;
            }

            Assert.AreEqual(true, isCohesion);
        }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:33,代码来源:DepthFirstSearchTests.cs

示例2: BreadthFirstPaths

 public BreadthFirstPaths(Graph graph, int s)
 {
     marked = new bool[graph.V()];
     edgeTo = new int[graph.V()];
     this.s = s;
     bfs(graph, s);
 }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:7,代码来源:BreadthFirstPaths.cs

示例3: DepthFirstPath

 public DepthFirstPath(Graph g, int s)
 {
     marked = new bool[g.V()];
     edgeTo = new int[g.V()];
     this.s = s;
     dfs(g, s);
 }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:7,代码来源:DepthFirstPath.cs

示例4: CC

        public CC(Graph g)
        {
            marked = new bool[g.V()];
            id = new int[g.V()];

            for (int s = 0; s < g.V(); s++)
            {
                if (!marked[s])
                {
                    dfs(g, s);
                    count++;
                }
            }
        }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:14,代码来源:CC.cs

示例5: DepthFirstPathTest

        public void DepthFirstPathTest()
        {
            string[] graphEdges = new[] {
                "0 5",
                "2 4",
                "2 3",
                "1 2",
                "0 1",
                "3 4",
                "3 5",
                "0 2"};

            var graph = new Graph(6, 8, graphEdges);

            DepthFirstPath search = new DepthFirstPath(graph, 0);

            var pathBuilder = new StringBuilder();
            for (int v = 0; v < graph.V(); v++)
            {
                if (search.HasPathTo(v))
                {
                    foreach (int x in search.PathTo(v))
                    {
                        if (x == 0)
                            pathBuilder.Append(x);
                        else
                        {
                            pathBuilder.Append(" - " + x);
                        }
                    }
                }
            }
        }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:33,代码来源:DepthFirstPathTests.cs

示例6: CCTest

        public void CCTest()
        {
            string[] graphEdges = new[] {
                "0 5",
                "4 3",
                "0 1",
                "9 12",
                "6 4",
                "5 4",
                "0 2",
                "11 12",
                "9 10",
                "0 6",
                "7 8",
                "9 11",
                "5 3"};

            var graph = new Graph(13, 13, graphEdges);

            CC cc = new CC(graph);
            int m = cc.Count();

            List<int>[] components = new List<int>[m];

            for (int i = 0; i < m; i++)
            {
                components[i] = new List<int>();
            }

            for (int v = 0; v < graph.V(); v++)
            {
                components[cc.Id(v)].Add(v);
            }

            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < m; i++)
            {
                foreach (int v in components[i])
                {
                    builder.Append(v + " ");
                }

                builder.AppendLine();
            }
        }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:45,代码来源:CCTests.cs

示例7: DepthFirstSearch

 public DepthFirstSearch(Graph g, int s)
 {
     marked = new bool[g.V()];
     dfs(g, s);
 }
开发者ID:elcrespito,项目名称:ClassicAlgorightms,代码行数:5,代码来源:DepthFirstSearch.cs


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