QuantEcon / lecture-julia.myst

Lecture source for "Quantitative Economics with Julia"
https://julia.quantecon.org/intro.html
52 stars 43 forks source link

Shortest Path exercise clarification, 27.5.1. Exercise 1 #291

Open klwlevy opened 6 months ago

klwlevy commented 6 months ago

When solving this exercise, it wasn't immediately clear to me that the graph must be directed. When allowing path traversal in both directions, for example allowing the path (27, 24) with cost 2.66 instead of just (24, 27), I found a shorter path from node 1 to node 100, namely this one with cost 117.61 instead of 160.55:

The shortest path from node 1 to 100 is 117.60999999999999 passing through the nodes [1, 2, 7, 10, 21, 25, 27, 24, 34, 42, 47, 45, 48, 51, 54, 57, 58, 61, 60, 72, 75, 82, 80, 86, 88, 89, 94, 95, 97, 98, 99, 100]

I changed the node numbers from 0:99 to 1:100 as I solved the exercise in Julia (Graphs.jl) with one-based indexing.

Maybe it is a good idea to clarify this in the exercise formulation, and maybe add the undirected case as an additional exercise?

jlperla commented 6 months ago

Thanks so much, I will take a look!