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


C# Graph.RemoveEdges方法代码示例

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


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

示例1: TestGraphCompressVertices

        public void TestGraphCompressVertices()
        {
            var graph = new Graph<Edge>();

            var vertex1 = graph.AddVertex(51, 1);
            var vertex2 = graph.AddVertex(51, 2);
            var vertex3 = graph.AddVertex(51, 3);
            var vertex4 = graph.AddVertex(51, 3);

            graph.AddEdge(vertex1, vertex2, new Edge()
            {
                Forward = true,
                Tags = 1
            }, null);
            graph.AddEdge(vertex2, vertex3, new Edge()
            {
                Forward = true,
                Tags = 2
            }, null);
            graph.AddEdge(vertex3, vertex4, new Edge()
            {
                Forward = true,
                Tags = 3
            }, null);

            graph.AddEdge(vertex4, vertex2, new Edge()
            {
                Forward = true,
                Tags = 4
            }, null);

            // make vertex4 obsolete.
            graph.RemoveEdges(vertex4);

            graph.Compress();

            Assert.AreEqual(3, graph.VertexCount);

            Assert.AreEqual(graph.GetEdges(vertex1).ToKeyValuePairs().Length, 1);
            Assert.AreEqual(graph.GetEdges(vertex2).ToKeyValuePairs().Length, 2);
            Assert.AreEqual(graph.GetEdges(vertex3).ToKeyValuePairs().Length, 1);
        }
开发者ID:cmberryau,项目名称:routing,代码行数:42,代码来源:GraphTests.cs

示例2: TestCompressVertices

        public void TestCompressVertices()
        {
            using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000,
                Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
            {
                var vertex1 = graph.AddVertex(51, 1);
                var vertex2 = graph.AddVertex(51, 2);
                var vertex3 = graph.AddVertex(51, 3);
                var vertex4 = graph.AddVertex(51, 3);

                graph.AddEdge(vertex1, vertex2, new Edge()
                {
                    Forward = true,
                    Tags = 1
                }, null);
                graph.AddEdge(vertex2, vertex3, new Edge()
                {
                    Forward = true,
                    Tags = 2
                }, null);
                graph.AddEdge(vertex3, vertex4, new Edge()
                {
                    Forward = true,
                    Tags = 3
                }, null);

                graph.AddEdge(vertex4, vertex2, new Edge()
                {
                    Forward = true,
                    Tags = 4
                }, null);

                // make vertex4 obsolete.
                graph.RemoveEdges(vertex4);

                graph.Compress();

                Assert.AreEqual(3, graph.VertexCount);

                Assert.AreEqual(graph.GetEdges(vertex1).ToKeyValuePairs().Length, 1);
                Assert.AreEqual(graph.GetEdges(vertex2).ToKeyValuePairs().Length, 2);
                Assert.AreEqual(graph.GetEdges(vertex3).ToKeyValuePairs().Length, 1);
            }
        }
开发者ID:cmberryau,项目名称:routing,代码行数:44,代码来源:MemoryMappedGraphTests.cs

示例3: TestGraphRemoveAllOneVertex

        public void TestGraphRemoveAllOneVertex()
        {
            var graph = new Graph<Edge>();

            var vertex1 = graph.AddVertex(51, 1);
            var vertex2 = graph.AddVertex(51, 2);
            var vertex3 = graph.AddVertex(51, 3);
            var vertex4 = graph.AddVertex(51, 3);

            graph.AddEdge(vertex1, vertex2, new Edge()
            {
                Forward = true,
                Tags = 1
            });
            graph.AddEdge(vertex2, vertex3, new Edge()
            {
                Forward = true,
                Tags = 2
            });
            graph.AddEdge(vertex3, vertex4, new Edge()
            {
                Forward = true,
                Tags = 3
            });

            graph.AddEdge(vertex4, vertex2, new Edge()
            {
                Forward = true,
                Tags = 4
            });

            graph.RemoveEdges(vertex2);
            Assert.IsFalse(graph.ContainsEdges(vertex2, vertex1));
            Assert.IsFalse(graph.ContainsEdges(vertex2, vertex3));
            Assert.IsFalse(graph.ContainsEdges(vertex4, vertex2));
            Assert.IsTrue(graph.ContainsEdges(vertex3, vertex4));
        }
开发者ID:cmberryau,项目名称:routing,代码行数:37,代码来源:GraphTests.cs

示例4: TestRemoveAllOneVertex

        public void TestRemoveAllOneVertex()
        {
            using (var graph = new Graph<Edge>(new MemoryMappedStream(new MemoryStream()), 1000,
                Edge.MapFromDelegate, Edge.MapToDelegate, Edge.SizeUints))
            {
                var vertex1 = graph.AddVertex(51, 1);
                var vertex2 = graph.AddVertex(51, 2);
                var vertex3 = graph.AddVertex(51, 3);
                var vertex4 = graph.AddVertex(51, 3);

                graph.AddEdge(vertex1, vertex2, new Edge()
                {
                    Forward = true,
                    Tags = 1
                });
                graph.AddEdge(vertex2, vertex3, new Edge()
                {
                    Forward = true,
                    Tags = 2
                });
                graph.AddEdge(vertex3, vertex4, new Edge()
                {
                    Forward = true,
                    Tags = 3
                });

                graph.AddEdge(vertex4, vertex2, new Edge()
                {
                    Forward = true,
                    Tags = 4
                });

                graph.RemoveEdges(vertex2);
                Assert.IsFalse(graph.ContainsEdges(vertex2, vertex1));
                Assert.IsFalse(graph.ContainsEdges(vertex2, vertex3));
                Assert.IsFalse(graph.ContainsEdges(vertex4, vertex2));
                Assert.IsTrue(graph.ContainsEdges(vertex3, vertex4));
            }
        }
开发者ID:cmberryau,项目名称:routing,代码行数:39,代码来源:MemoryMappedGraphTests.cs


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