Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 3: shortest path has changed? #2

Open
AllenDowney opened this issue Nov 10, 2024 · 0 comments
Open

Chapter 3: shortest path has changed? #2

AllenDowney opened this issue Nov 10, 2024 · 0 comments

Comments

@AllenDowney
Copy link
Owner

Submitted by a reader:

Think Complexity version 2.6.3

This example from chapter 3 in the book expects a mean path length of 1, but with networkx version 3.4.1, the function returns 0.666.

Book:
"And we can test it with a small ring lattice:

PastedGraphic-2.png

In this example, all 3 nodes are connected to each other, so the mean path length is 1."

Notebook:

PastedGraphic-1.png

I modified the functions to investigate and see that a path length of 0 is being returned for the distance from a node to itself. Maybe the way shortest_path_length works changed?

PastedGraphic-3.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant