visualizations

Programmatic visualizations
git clone git://git.laack.co/visualizations.git
Log | Files | Refs | README

commit c59e50db11d827012b7dccd8f0de0ad9a80e1381
parent 79fb24e2419c6e07296f6562bc75e459f0b9277c
Author: Andrew Laack <andrew@laack.co>
Date:   Sat, 19 Sep 2026 20:37:07 -0500

Recording for blog post

Diffstat:
Mgraph/prim-rlib.py | 7+++++--
Mgraph/prim.py | 13++++++++-----
2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/graph/prim-rlib.py b/graph/prim-rlib.py @@ -9,6 +9,9 @@ RADIUS = 5 pr.init_window(5120,1440, "prim") +EDGEGRAY =( 20, 20, 20, 255 ) + + class Vertex(): def __init__(self, x, y): self.x = x @@ -18,7 +21,7 @@ class Vertex(): if self.visited: pr.draw_circle(int(self.x),int(self.y), RADIUS, pr.WHITE) else: - pr.draw_circle(int(self.x),int(self.y), RADIUS, pr.GRAY) + pr.draw_circle(int(self.x),int(self.y), RADIUS, pr.DARKGRAY) class Edge(): def __init__(self, v1, v2): self.v1 = v1 @@ -81,7 +84,7 @@ while True: pr.clear_background(pr.BLACK) for edge in edge_list: - edge.draw_edge(pr.DARKGRAY) + edge.draw_edge(EDGEGRAY) first = False for vertex in graph: diff --git a/graph/prim.py b/graph/prim.py @@ -5,10 +5,10 @@ import math pygame.init() -display = pygame.display.set_mode((5120,1440)) +display = pygame.display.set_mode((1920,1080)) -VERTICES = 10000 -EDGES = 100000 +VERTICES = 250 +EDGES = 1000 white = (255, 255, 255) red = (255, 0, 0) @@ -42,8 +42,8 @@ class Edge(): graph = {} for i in range(0,VERTICES): - x = random.random() * 5120 - y = random.random() * 1440 + x = random.random() * 1920 + y = random.random() * 1080 graph[Vertex(x,y)] = [] @@ -79,6 +79,7 @@ first = True to_draw_vert = [] to_draw_edge = [] +#itr = 0 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: @@ -124,5 +125,7 @@ while True: for edge in graph[new_vertex]: if not edge.v1 in visited_vertices or not edge.v2 in visited_vertices: heapq.heappush(edge_heap, edge) + #pygame.image.save(display,"out"+str(itr)+".jpg") + #itr += 1 pygame.display.update()