Skip to content

Conversation

@amcandio
Copy link
Contributor

@amcandio amcandio commented Oct 18, 2025

Floating Point Considerations

As discussed in previous issues and PRs (e.g., #4972, #4592, #8316), users sometimes face unexpected results when using floating point values such as edge weights or capacities. These issues are often caused by rounding errors, not bugs in the algorithms.

The moment floating point numbers are used, all results become approximate. So to avoid confusion, we update tutorial to clarify these considerations.

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Thanks @amcandio , I think this is a step in the right direction. One idea that occurred to me when considering how to better document numerical precision was to add a standard reference document (similar to what is done for seeding/randomness) and then link to this reference doc from the functions where precision issues are prominent.

That's too much for this PR though - I'm +1 for getting this information somewhere visible in the docs and this seems a sensible place to me!

One style nit - could we get the line limits down to something more reasonable (80 or 88 or 110 chars). In principle the linter should be doing this file is clearly not being picked up 🙃

amcandio and others added 2 commits October 20, 2025 22:46
Co-authored-by: Ross Barnowski <rossbar@caltech.edu>
@amcandio
Copy link
Contributor Author

Thanks! I fixed the line length. We can add a more-detail doc like https://networkx.org/documentation/stable/reference/randomness.html in a separate PR.

amcandio and others added 3 commits October 21, 2025 18:27
Co-authored-by: Dan Schult <dschult@colgate.edu>
Copy link
Member

@dschult dschult left a comment

Choose a reason for hiding this comment

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

Thanks @amcandio

Copy link
Contributor

@rossbar rossbar left a comment

Choose a reason for hiding this comment

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

Thanks @amcandio !

@rossbar rossbar merged commit 82d08d9 into networkx:main Oct 23, 2025
52 checks passed
@dschult dschult added this to the 3.6 milestone Oct 23, 2025
@amcandio amcandio deleted the fp-considerations-tutorial branch October 24, 2025 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

floating-point Issues that ultimate stem from numerical precision type: Documentation

Development

Successfully merging this pull request may close these issues.

3 participants