Skip to content

Chapter 3: shortest path has changed? #2

@AllenDowney

Description

@AllenDowney

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions