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


C# Graph.IsWeaklyConnected方法代码示例

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


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

示例1: Directed

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

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

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

            Assert.IsFalse(graph.IsWeaklyConnected());

            graph.AddEdge(vertex2, vertex4);

            Assert.IsTrue(graph.IsWeaklyConnected());

            graph.RemoveEdge(vertex2, vertex3);

            Assert.IsTrue(graph.IsWeaklyConnected());

            graph.RemoveEdge(vertex1, vertex3);

            Assert.IsFalse(graph.IsWeaklyConnected());
        }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:31,代码来源:IsWeaklyConnected.cs

示例2: IsWeaklyConnectedExample

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

            // Add 4 vertices to the graph
            var vertex1 = graph.AddVertex(1);
            var vertex2 = graph.AddVertex(2);
            var vertex3 = graph.AddVertex(3);
            var vertex4 = graph.AddVertex(4);

            // Add edges to the vertices
            graph.AddEdge(vertex1, vertex2);
            graph.AddEdge(vertex3, vertex2);
            graph.AddEdge(vertex1, vertex3);

            // The graph will not be strongly connected, since
            // vertex vertex4 is not reachable from every other vertex
            Assert.IsFalse(graph.IsWeaklyConnected());

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

            // Now the graph is strongly connected
            Assert.IsTrue(graph.IsWeaklyConnected());
        }
开发者ID:havok,项目名称:ngenerics,代码行数:26,代码来源:GraphExamples.cs

示例3: ExceptionEmptyUndirected

 public void ExceptionEmptyUndirected()
 {
     var graph = new Graph<int>(false);
     graph.IsWeaklyConnected();
 }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:5,代码来源:IsWeaklyConnected.cs

示例4: ExceptionEmptyDirected

 public void ExceptionEmptyDirected()
 {
     var graph = new Graph<int>(true);
     graph.IsWeaklyConnected();
 }
开发者ID:GTuritto,项目名称:ngenerics,代码行数:5,代码来源:IsWeaklyConnected.cs


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