本文整理汇总了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());
}
示例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());
}
示例3: ExceptionEmptyUndirected
public void ExceptionEmptyUndirected()
{
var graph = new Graph<int>(false);
graph.IsWeaklyConnected();
}
示例4: ExceptionEmptyDirected
public void ExceptionEmptyDirected()
{
var graph = new Graph<int>(true);
graph.IsWeaklyConnected();
}