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


C# AdjacencyGraph.TryGetEdge方法代码示例

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


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

示例1: 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

示例2: MinimalCutFind

        public void MinimalCutFind(AdjacencyGraph<int, Edge<int>> graph)
        {
            if (graph == null)
                throw new ArgumentNullException("graph");

            List<int> results = new List<int>();

            for (int i = 1; i <= (graph.VertexCount * graph.VertexCount); i++)
            {
                while (graph.VertexCount > 2)
                {
                    // get the vertext to delete
                    int x = _random.Next(0, graph.VertexCount);
                    int vertexToDelete = graph.Vertices.ElementAt(x);

                    // get the target vertex to merge to
                    IEnumerable<Edge<int>> e = new List<Edge<int>>();
                    graph.TryGetOutEdges(vertexToDelete, out e);

                    int r = _random.Next(0, e.Count());
                    int vertexToMergeTo = e.ElementAt(r).Target;

                    // list of edges which need to be merged based on the vertex to delete
                    IEnumerable<Edge<int>> edgesToMerge = new List<Edge<int>>();
                    graph.TryGetOutEdges(vertexToDelete, out edgesToMerge);

                    // temp lists to store the edges to add and remove.
                    List<Edge<int>> edgesToRemove = new List<Edge<int>>();
                    List<Edge<int>> edgesToAdd = new List<Edge<int>>();

                    // for each edge, create a new edge linked to the target vertex.  If the target is the same remove.
                    foreach (Edge<int> edge in edgesToMerge)
                    {
                        if (vertexToMergeTo == edge.Target)
                        {
                            edgesToRemove.Add(edge);
                        }
                        else
                        {
                            Edge<int> newEdge = new Edge<int>(vertexToMergeTo, edge.Target);
                            edgesToAdd.Add(newEdge);
                            Edge<int> newEdgeB = new Edge<int>(edge.Target, vertexToMergeTo);
                            edgesToAdd.Add(newEdgeB);

                            edgesToRemove.Add(edge);
                            Edge<int> newEdgeD = null;
                            graph.TryGetEdge(edge.Target, edge.Source, out newEdgeD);
                            edgesToRemove.Add(newEdgeD);
                        }
                    }

                    // remove old vertexes
                    foreach (Edge<int> edge in edgesToRemove)
                    {
                        graph.RemoveEdge(edge);
                    }

                    // remove old vertexes
                    foreach (Edge<int> edge in edgesToAdd)
                    {
                        graph.AddEdge(edge);
                    }

                    graph.RemoveVertex(vertexToDelete);
                }
            }
            IEnumerable<Edge<int>> edges1 = new List<Edge<int>>();
            IEnumerable<Edge<int>> edges2 = new List<Edge<int>>();
            graph.TryGetOutEdges(graph.Vertices.ElementAt(0), out edges1);
            graph.TryGetOutEdges(graph.Vertices.ElementAt(1), out edges2);
            results.Add(edges1.Count());
            Console.Write(results.Min());

            Console.ReadLine();
        }
开发者ID:GrimRanger,项目名称:ProbabilityTheory,代码行数:75,代码来源:MinimalCutFinder.cs


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