在 C# 中生成平面图
我正在寻找一种在 C# 中生成随机平面图的方法。我研究了一些算法,如 Voronoi 图、Delaunay 三角剖分和凸包算法。它们非常有用,我设法生成了一个图表,但我面临着一些尚未解决的边缘情况。请记住,我有两个主要约束:最小/最大边长度和最小/最大角度(任意两条边之间),目标顶点/边计数中存在错误是可以的。
我认为有两种方法可以生成该图: 答:有一些来源提供了所有可能的平面图,我需要一个小的平面图,所以这对我有用,但我不知道如何将其绘制在没有交叉点的平面图上。 B. 从几何角度生成它,这是我最理解的。
我发现一些论文旨在非常快速地生成大图,所以这对我来说很复杂。我可以接受经过测试的缓慢算法/库/代码。
I am looking for a way to generate a random planar graph in C#. I've looked into some algorithms like Voronoi Diagram, Delaunay Triangulation and convex hull algorithms. They were quit useful and I managed to generate a graph but I am facing some edge cases that I didn't solve yet. Put in mind that I have 2 main constraints: min/max edge length and min/max angle(between any 2 edges), it is okay to have error in target vertex/edge count.
I think there are 2 ways to generate that graph:
A. There are sources that has all possible planar graphs, I need small one so this works for me, but I don't know how to plot it on a plan without intersections.
B. Generating it geometry-wise, this is what I understand the most.
I found some papers aimed for very fast generation for big graphs so it is complicated for me. I am okay with a tested slow algorithm/library/code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过以下方式创建随机最大平面图:
如果您不需要最大平面图而只想要随机图,则从图中删除边。
这是将图形嵌入到表面上的问题,而不一定是图形结构的问题。移动顶点并更改角度和边长。您可以尝试使用任何平面图绘制算法来生成嵌入,然后使用弹簧嵌入算法之类的算法来尝试修改嵌入以匹配您的约束。
You can create a random maximal planar graph by:
If you do not want a maximal planar graph and just want a random graph then remove edges from the graph.
This is an issue with the embedding the graph onto a surface and not necessarily with the structure of the graph as you can move a vertex and change the angles and edge lengths. You can try using any planar graph drawing algorithm to generate an embedding and then use something like a spring-embedding algorithm to try to modify the embedding to match your constraints.