luogu-dev / cyaron

CYaRon: Yet Another Random Olympic-iNformatics test data generator
GNU Lesser General Public License v3.0
1.32k stars 164 forks source link

关于图的一个问题 #66

Closed william-song-shy closed 4 years ago

william-song-shy commented 4 years ago

我随机生成了一个图,希望能够在它的基础上随机新增一条不重复的边,我应该怎么做?

lin-toto commented 4 years ago

自己写

scmmm commented 4 years ago

自己写

william-song-shy commented 4 years ago
while (1):
        a=randint(1,n)
        b=randint(1,n)
        ed=Edge(a,b,1)
        if ed not in tree.iterate_edges() and a<b:
            tree.add_edge(a,b)
            break

谢谢,问题已解决