bgneal@5: """Tests our regular graph making abilities by displaying examples. bgneal@5: bgneal@5: """ bgneal@5: import string bgneal@5: bgneal@5: from Graph import Vertex, Graph, GraphError bgneal@5: from GraphWorld import GraphWorld, CircleLayout bgneal@5: bgneal@5: def main(script_name, n, k): bgneal@5: bgneal@5: # Attempt to create a regular graph of order n and degree k bgneal@5: bgneal@5: n, k = int(n), int(k) bgneal@5: bgneal@5: labels = string.ascii_lowercase + string.ascii_uppercase bgneal@5: vs = [Vertex(c) for c in labels[:n]] bgneal@5: bgneal@5: # create graph and layout bgneal@5: g = Graph(vs) bgneal@5: g.add_regular_edges(k) bgneal@5: layout = CircleLayout(g) bgneal@5: bgneal@5: # draw the graph bgneal@5: bgneal@5: gw = GraphWorld() bgneal@5: gw.show_graph(g, layout) bgneal@5: gw.mainloop() bgneal@5: bgneal@5: bgneal@5: if __name__ == '__main__': bgneal@5: import sys bgneal@5: try: bgneal@5: main(*sys.argv) bgneal@5: except GraphError, ex: bgneal@5: sys.stderr.write("GraphError: {}\n".format(ex))