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


C# Vertex.GetEmanatingEdgeTo方法代码示例

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


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

示例1: Directed

        public void Directed()
        {
            var vertex1 = new Vertex<int>(3);
            var vertex2 = new Vertex<int>(5);
            var vertex3 = new Vertex<int>(8);

            var graph = new Graph<int>(true);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex1, vertex2);
            graph.AddEdge(vertex3, vertex1);

            var edgeList = vertex3.IncidentEdges;

            Assert.AreEqual(edgeList.Count, 1);
            AssertContainsEdges(edgeList, true,
                                vertex3.GetEmanatingEdgeTo(vertex1)
                );

            edgeList = vertex1.IncidentEdges;

            Assert.AreEqual(edgeList.Count, 2);

            AssertContainsEdges(edgeList, true,
                                vertex1.GetEmanatingEdgeTo(vertex2),
                                vertex3.GetEmanatingEdgeTo(vertex1)
                );
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:30,代码来源:IncidentEdges.cs

示例2: Directed

        public void Directed()
        {
            var vertex1 = new Vertex<int>(3);
            var vertex2 = new Vertex<int>(5);
            var vertex3 = new Vertex<int>(8);

            var graph = new Graph<int>(true);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            graph.AddEdge(vertex1, vertex2);

            var edge = vertex1.GetEmanatingEdgeTo(vertex2);
            Assert.AreEqual(edge.FromVertex, vertex1);
            Assert.AreEqual(edge.ToVertex, vertex2);

            edge = vertex2.GetEmanatingEdgeTo(vertex1);
            Assert.IsNull(edge);
            Assert.IsNull(vertex1.GetEmanatingEdgeTo(vertex3));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:20,代码来源:GetEmanatingEdgeTo.cs

示例3: UndirectedEnumerator

        public void UndirectedEnumerator()
        {
            var vertex1 = new Vertex<int>(3);
            var vertex2 = new Vertex<int>(5);
            var vertex3 = new Vertex<int>(8);

            var graph = new Graph<int>(false);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex1, vertex2);
            graph.AddEdge(vertex3, vertex1);

            var edgeList = vertex1.EmanatingEdges;

            Assert.AreEqual(edgeList.Count, 2);

            AssertContainsEdges(edgeList, true,
                                vertex1.GetEmanatingEdgeTo(vertex2),
                                vertex1.GetEmanatingEdgeTo(vertex3),
                                vertex3.GetEmanatingEdgeTo(vertex1));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:23,代码来源:EmanatingEdges.cs

示例4: GetEmanatingEdgeToExample

        public void GetEmanatingEdgeToExample()
        {
            // Create two new vertices
            var vertex1 = new Vertex<int>(2);
            var vertex2 = new Vertex<int>(4);

            // Create a graph, and add the vertices to
            // the graph
            var graph = new Graph<int>(true);
            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);

            // Add an edge from vertex1 to vertex vertex2
            graph.AddEdge(vertex1, vertex2);

            // Retrieve the emanating edge from vertex1 to vertex2
            var edge = vertex1.GetEmanatingEdgeTo(vertex2);

            // Which will be a valid edge
            Assert.IsNotNull(edge);

            // Requesting the emanating edge from vertex2 to vertex1
            // will result in a null being returned - the
            // edge is directed from vertex1 to vertex2.
            edge = vertex2.GetEmanatingEdgeTo(vertex1);
            Assert.IsNull(edge);
        }
开发者ID:havok,项目名称:ngenerics,代码行数:27,代码来源:VertexExamples.cs


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