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


C# Graph.ContainsVertex方法代码示例

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


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

示例1: Directed

        public void Directed()
        {
            var graph = new Graph<int>(true);

            for (var i = 0; i < 20; i++)
            {
                var vertex = new Vertex<int>(i);
                graph.AddVertex(vertex);

                Assert.AreEqual(graph.Vertices.Count, i + 1);
                Assert.IsTrue(graph.ContainsVertex(i));
                Assert.IsTrue(graph.ContainsVertex(vertex));
                Assert.AreEqual(graph.Edges.Count, 0);
            }
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:15,代码来源:AddVertex.cs

示例2: Simple

        public void Simple()
        {
            var graph = new Graph<int>(false);

            for (var i = 0; i < 20; i++)
            {
                var vertex = new Vertex<int>(i);
                graph.AddVertex(vertex);

                Assert.IsTrue(graph.ContainsVertex(i));
                Assert.IsTrue(graph.ContainsVertex(vertex));
            }

            Assert.IsFalse(graph.ContainsVertex(new Vertex<int>(3)));
            Assert.IsFalse(graph.ContainsVertex(21));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:16,代码来源:ContainsVertex.cs

示例3: ContainsVertexValueExample

        public void ContainsVertexValueExample()
        {
            // Initialize a new graph instance
            var graph = new Graph<int>(true);

            // Add two vertices to the graph
            graph.AddVertex(1);
            graph.AddVertex(2);

            // The graph will contain vertex values 1 and 2
            Assert.IsTrue(graph.ContainsVertex(1));
            Assert.IsTrue(graph.ContainsVertex(2));

            // But not vertex value 3
            Assert.IsFalse(graph.ContainsVertex(3));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:16,代码来源:GraphExamples.cs

示例4: ContainsVertexExample

        public void ContainsVertexExample()
        {
            // Initialize a new graph instance
            var graph = new Graph<int>(true);

            // Add two vertices to the graph
            var vertex1 = graph.AddVertex(1);
            var vertex2 = graph.AddVertex(2);

            // Create a vertex that doesn't form part of the graph
            var vertex3 = new Vertex<int>(3);

            // The graph will contain vertices vertex1 and vertex2
            Assert.IsTrue(graph.ContainsVertex(vertex1));
            Assert.IsTrue(graph.ContainsVertex(vertex2));

            // But not vertex vertex3
            Assert.IsFalse(graph.ContainsVertex(vertex3));
        }
开发者ID:havok,项目名称:ngenerics,代码行数:19,代码来源:GraphExamples.cs

示例5: UndirectedVertexValue

        public void UndirectedVertexValue()
        {
            var graph = new Graph<int>(false);

            for (var i = 0; i < 20; i++)
            {
                graph.AddVertex(i);

                Assert.AreEqual(graph.Vertices.Count, i + 1);
                Assert.IsTrue(graph.ContainsVertex(i));
                Assert.AreEqual(graph.Edges.Count, 0);
            }
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:13,代码来源:AddVertex.cs


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