Skip to content

Enforce default physical layout for Network spaces#3355

Merged
quaquel merged 3 commits intomesa:mainfrom
codebreaker32:update_network
Feb 21, 2026
Merged

Enforce default physical layout for Network spaces#3355
quaquel merged 3 commits intomesa:mainfrom
codebreaker32:update_network

Conversation

@codebreaker32
Copy link
Copy Markdown
Collaborator

Summary:
This PR updates the Network space to ensure that Cell._position is never None for networks, moving the responsibility of position generation out of the visualization layer and into the model layer

Motivation:
Previously, initializing a purely topological network (layout=None) resulted in empty cell positions. This forced the visualization backends to manually calculate fallback layouts (like spring_layout), leading to brittle rendering logic and misaligned bounding boxes. As discussed in #3345, enforcing a default layout at the model level solves this. nx.circular_layout was chosen as the default because it is cheaper for extremely large networks as well.

Key Changes:

  • Updated Network.__init__ to use nx.circular_layout as the default layout argument.
  • Now an Exception will be raised if user explicitly passes layout=None.

This change paves the way for #3345 to directly use Cell.position for visualization tasks.

@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔵 -0.4% [-0.8%, +0.0%] 🔵 +0.3% [-0.2%, +0.7%]
BoltzmannWealth large 🔵 -0.9% [-1.5%, -0.4%] 🔵 +0.3% [-0.1%, +0.5%]
Schelling small 🔵 -0.8% [-1.0%, -0.7%] 🔵 -0.1% [-0.2%, +0.0%]
Schelling large 🔵 -0.3% [-0.5%, +0.0%] 🔵 -0.3% [-0.5%, -0.2%]
WolfSheep small 🔵 +0.6% [+0.3%, +0.8%] 🔵 +0.2% [-0.0%, +0.4%]
WolfSheep large 🔵 +0.4% [+0.1%, +0.7%] 🔵 +0.3% [-0.0%, +0.7%]
BoidFlockers small 🔵 +1.0% [+0.3%, +1.6%] 🔵 +0.3% [-0.0%, +0.7%]
BoidFlockers large 🔵 +1.1% [-0.4%, +2.5%] 🔵 +0.5% [-0.4%, +1.5%]

@codebreaker32 codebreaker32 changed the title Enforce default physical coordinates for Network spaces using nx.circular_layout Enforce default physical layout for Network spaces Feb 20, 2026
@quaquel quaquel merged commit cb11446 into mesa:main Feb 21, 2026
14 checks passed
@quaquel quaquel added the enhancement Release notes label label Feb 23, 2026
@codebreaker32 codebreaker32 deleted the update_network branch March 9, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants