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


C# Vertex.HasEmanatingEdgeTo方法代码示例

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


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

示例1: OtherVertex

        public void OtherVertex()
        {
            var graph = new Graph<int>(true);
            var vertex1 = new Vertex<int>(1);
            var vertex2 = new Vertex<int>(2);
            var vertex3 = new Vertex<int>(3);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

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

            Assert.AreEqual(graph.Edges.Count, 3);
            Assert.AreEqual(graph.Vertices.Count, 3);

            Assert.IsTrue(graph.RemoveEdge(vertex1, vertex2));
            Assert.AreEqual(graph.Edges.Count, 2);
            Assert.IsFalse(vertex1.HasEmanatingEdgeTo(vertex2));
            Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex2));

            Assert.IsTrue(graph.RemoveEdge(vertex3, vertex2));
            Assert.AreEqual(graph.Edges.Count, 1);

            Assert.IsFalse(vertex1.HasEmanatingEdgeTo(vertex2));
            Assert.IsFalse(vertex3.HasEmanatingEdgeTo(vertex2));
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:29,代码来源:RemoveEdge.cs

示例2: HasEmanatingEdgeToExample

        public void HasEmanatingEdgeToExample()
        {
            // 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);

            // vertex1 has an emanating edge to vertex2
            Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex2));

            // But vertex2 does not have an emanating edge to vertex1
            Assert.IsFalse(vertex2.HasEmanatingEdgeTo(vertex1));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:21,代码来源:VertexExamples.cs

示例3: VerticesAndWeightUndirected

        public void VerticesAndWeightUndirected()
        {
            var graph = new Graph<int>(false);
            var vertex1 = new Vertex<int>(4);
            var vertex2 = new Vertex<int>(5);
            var vertex3 = new Vertex<int>(6);

            graph.AddVertex(vertex1);
            graph.AddVertex(vertex2);
            graph.AddVertex(vertex3);

            graph.AddEdge(vertex1, vertex2, 10);
            graph.AddEdge(vertex1, vertex3, 12);
            graph.AddEdge(vertex2, vertex3, 14);

            Assert.AreEqual(graph.Edges.Count, 3);

            Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex2));
            Assert.IsTrue(vertex1.HasEmanatingEdgeTo(vertex3));
            Assert.IsTrue(vertex2.HasEmanatingEdgeTo(vertex3));

            Assert.IsTrue(vertex2.HasEmanatingEdgeTo(vertex1));
            Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex1));
            Assert.IsTrue(vertex3.HasEmanatingEdgeTo(vertex2));

            Assert.IsTrue(graph.ContainsEdge(vertex1, vertex2));
            Assert.IsTrue(graph.ContainsEdge(vertex1, vertex3));
            Assert.IsTrue(graph.ContainsEdge(vertex2, vertex3));

            Assert.IsTrue(graph.ContainsEdge(vertex2, vertex1));
            Assert.IsTrue(graph.ContainsEdge(vertex3, vertex1));
            Assert.IsTrue(graph.ContainsEdge(vertex3, vertex2));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:33,代码来源:AddEdge.cs


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