Skip to content

Commit 5bbe0e0

Browse files
author
Daniel Precioso, PhD
committed
Explain spring layout
1 parent e68216e commit 5bbe0e0

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

modules/networks/fundamentals.qmd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,11 @@ edge_list = [
398398
# Create a graph from the edge list
399399
G_actors = nx.from_edgelist(edge_list)
400400
# Draw the graph
401-
pos = nx.spring_layout(G_actors)
401+
pos = nx.spring_layout(G_actors, k=0.15, iterations=20)
402+
# k controls the distance between the nodes and varies between 0 and 1
403+
# iterations is the number of times simulated annealing is run
404+
# default k=0.1 and iterations=50
405+
402406
nx.draw(
403407
G_actors,
404408
pos=pos,

0 commit comments

Comments
 (0)