Skip to content

Fix issue #2812#2821

Merged
tpike3 merged 1 commit intomesa:mainfrom
Tosiekdev:network-get-neighborhood-sorted-by-distance
Jul 26, 2025
Merged

Fix issue #2812#2821
tpike3 merged 1 commit intomesa:mainfrom
Tosiekdev:network-get-neighborhood-sorted-by-distance

Conversation

@Tosiekdev
Copy link
Copy Markdown
Contributor

Summary

get_neighborhood function in the NetworkGrid now returns node ids sorted by the distance from the source node.

Bug / Issue

Fixes this. Before this changes mentioned function was returning node_ids sorted by its values, and not the distance.

Implementation

Dictionary returned by the NetworkX's single_source_shortest_path_length is sorted by the value of the items, and then the node_ids are returned.

Testing

I have run exsisting tests

@github-actions
Copy link
Copy Markdown

Performance benchmarks:

Model Size Init time [95% CI] Run time [95% CI]
BoltzmannWealth small 🔴 +4.3% [+3.6%, +5.0%] 🔵 +0.5% [+0.3%, +0.6%]
BoltzmannWealth large 🔵 +0.7% [+0.3%, +1.1%] 🔴 +4.4% [+3.1%, +5.5%]
Schelling small 🔵 +0.9% [+0.7%, +1.1%] 🔵 +1.8% [+1.5%, +2.1%]
Schelling large 🔵 +1.4% [+0.6%, +2.1%] 🔴 +10.5% [+5.8%, +15.1%]
WolfSheep small 🔵 -0.5% [-0.7%, -0.2%] 🔵 -0.6% [-0.8%, -0.4%]
WolfSheep large 🔵 +0.3% [-0.6%, +1.1%] 🔵 +4.4% [+3.0%, +5.5%]
BoidFlockers small 🔵 +1.1% [+0.6%, +1.6%] 🔵 -0.6% [-0.7%, -0.4%]
BoidFlockers large 🔵 +1.0% [+0.7%, +1.4%] 🔵 +0.0% [-0.1%, +0.2%]

@tpike3 tpike3 added the bug Release notes label label Jul 26, 2025
Copy link
Copy Markdown
Member

@tpike3 tpike3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Tosiekdev!

Merge note: I am ignoring the pre-commit issue as it is based on ruff upgrade and not relevant to PR.

@tpike3 tpike3 merged commit 0dbe73a into mesa:main Jul 26, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Release notes label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NetworkGrid's method get_neighborhood returns neighborhood sorted by node id

2 participants