From 7e5b626b5c2f98f0e30556525be897693998f397 Mon Sep 17 00:00:00 2001 From: Jeremy Langley Date: Sat, 20 Jun 2020 18:02:58 -0700 Subject: [PATCH] Update force_directed_layout.py a more pythonic way to do this. --- force_directed_layout.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/force_directed_layout.py b/force_directed_layout.py index 0636030..ca22242 100644 --- a/force_directed_layout.py +++ b/force_directed_layout.py @@ -26,8 +26,7 @@ def run(edges, iterations=1000, force_strength=5.0, dampening=0.01, d = 3 if is_3d else 2 nodes = {n: {"velocity": [0.0] * d, "force": [0.0] * d} for n in nodes} - # Repeat n times (is there a more Pythonic way to do this?) - for _ in repeat(None, iterations): + for _ in range(iterations): # Add in Coulomb-esque node-node repulsive forces for node1, node2 in combinations(nodes.values(), 2):