本文整理汇总了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);
}
示例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);
}
}
示例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));
}
示例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));
}
}