[英]Generating a random planar graph in python
I am looking to generate a random planar graph<\/strong> in python with around 20 vertices<\/strong> .我希望在 python 中生成一个具有大约 20 个顶点<\/strong>的随机平面图<\/strong>。 I checked out this planar graph generator<\/a> but two problems emerged:
我检查了这个
平面图生成器<\/a>,但出现了两个问题:
With that said, is there a simpler way to randomly generate a relatively small planar graph in python?话虽如此,有没有一种更简单的方法可以在 python 中随机生成一个相对较小的平面图?
Create required number of nodes
Assign random x,y locations to the nodes.
WHILE nodes with no connected edges
Select N a random node with no edge
LOOP select M a different node at random
IF edge N-M does NOT intersect previous edges
Add N-M edge to graph
BREAK out of LOOP
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.