def main(script, n='5', p='0.5', *args): import string n=int(n) p=float(p) labels = string.ascii_lowercase + string.ascii_uppercase vs = [Vertex(c) for c in labels[:n]] g = Graph(vs) g.add_random_edges(p) print(g)
layout = CircleLayout(g) g.add_regular_edges(9, 100) # draw the graph gw = GraphWorld() gw.show_graph(g, layout) gw.mainloop() # test random graph alphabet = 'abcdefghijklmnopqrstuvwxyz' vs = [] for v in range(24): vs.append(Vertex(alphabet[v])) g = RandomGraph(vs) layout = CircleLayout(g) g.add_random_edges(0.05) # test connectedness of graphs if g.is_connected(): print "The graph is connected." else: print "The graph is not connected." print "done" # draw the graph gw = GraphWorld() gw.show_graph(g, layout) gw.mainloop()