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


C# Graph.SetVertex方法代码示例

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


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

示例1: TestArguments

        public void TestArguments()
        {
            using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000, 
                Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
            {
                uint vertex1 = graph.AddVertex(0, 0);
                uint vertex2 = graph.AddVertex(0, 0);
                uint vertex3 = 3;

                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.AddEdge(vertex3, vertex1, new Edge(), null);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.AddEdge(vertex1, vertex3, new Edge(), null);
                });
                Assert.Catch<ArgumentException>(() =>
                {
                    graph.AddEdge(vertex1, vertex1, new Edge(), null);
                });
                Assert.Catch<ArgumentException>(() =>
                {
                    graph.AddEdge(vertex1, vertex1, new Edge(), null);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.ContainsEdges(vertex3, vertex1);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.ContainsEdges(vertex1, vertex3);
                });
                Edge edge;
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.GetEdge(vertex3, vertex1, out edge);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.GetEdge(vertex1, vertex3, out edge);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.GetEdges(vertex3);
                });
                Assert.Catch<ArgumentOutOfRangeException>(() =>
                {
                    graph.SetVertex(vertex3, 10, 10);
                });
            }
        }
开发者ID:cmberryau,项目名称:routing,代码行数:52,代码来源:MemoryMappedGraphTests.cs

示例2: TestGraphAddVertex

        public void TestGraphAddVertex()
        {
            var graph = new Graph<Edge>();
            var vertex = graph.AddVertex(51, 4);

            float latitude, longitude;
            graph.GetVertex(vertex, out latitude, out longitude);
            Assert.AreEqual(51, latitude);
            Assert.AreEqual(4, longitude);
            graph.SetVertex(vertex, 52, 5);
            graph.GetVertex(vertex, out latitude, out longitude);
            Assert.AreEqual(52, latitude);
            Assert.AreEqual(5, longitude);

            var edges =  graph.GetEdges(vertex).ToKeyValuePairs();
            Assert.AreEqual(0, edges.Length);

            Assert.IsFalse(graph.GetVertex(100, out latitude, out longitude));
        }
开发者ID:cmberryau,项目名称:routing,代码行数:19,代码来源:GraphTests.cs

示例3: TestGraphArguments

        public void TestGraphArguments()
        {
            // create graph with one vertex and start adding vertex2.
            var graph = new Graph<Edge>();
            uint vertex1 = graph.AddVertex(0, 0);
            uint vertex2 = graph.AddVertex(0, 0);
            uint vertex3 = 3;

            Assert.Catch<ArgumentOutOfRangeException>(() => {
                graph.AddEdge(vertex3, vertex1, new Edge(), null);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.AddEdge(vertex1, vertex3, new Edge(), null);
            });
            Assert.Catch<ArgumentException>(() =>
            {
                graph.AddEdge(vertex1, vertex1, new Edge(), null);
            });
            Assert.Catch<ArgumentException>(() =>
            {
                graph.AddEdge(vertex1, vertex1, new Edge(), null);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.ContainsEdges(vertex3, vertex1);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.ContainsEdges(vertex1, vertex3);
            });
            Edge edge;
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.GetEdge(vertex3, vertex1, out edge);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.GetEdge(vertex1, vertex3, out edge);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.GetEdges(vertex3);
            });
            Assert.Catch<ArgumentOutOfRangeException>(() =>
            {
                graph.SetVertex(vertex3, 10, 10);
            });
        }
开发者ID:cmberryau,项目名称:routing,代码行数:49,代码来源:GraphTests.cs

示例4: TestVertex

        public void TestVertex()
        {
            using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000, Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
            {
                var vertex = graph.AddVertex(51, 4);

                float latitude, longitude;
                graph.GetVertex(vertex, out latitude, out longitude);
                Assert.AreEqual(51, latitude);
                Assert.AreEqual(4, longitude);
                graph.SetVertex(vertex, 52, 5);
                graph.GetVertex(vertex, out latitude, out longitude);
                Assert.AreEqual(52, latitude);
                Assert.AreEqual(5, longitude);

                var edges =  graph.GetEdges(vertex).ToKeyValuePairs();
                Assert.AreEqual(0, edges.Length);

                Assert.IsFalse(graph.GetVertex(100, out latitude, out longitude));
            }
        }
开发者ID:cmberryau,项目名称:routing,代码行数:21,代码来源:MemoryMappedGraphTests.cs


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