egonSchiele / grokking_algorithms

Code for the book Grokking Algorithms (https://amzn.to/29rVyHf)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

7.1_C Answer - 4

nazjude opened this issue · comments

Hi, thanks for this great work,

Yes, negative weighted edge there in 7.1 C graph, but no negative cycle, right?

Thus we do have a shortest path from start to finish, whose weight is 4, true?

Screenshot 2020-01-30 at 1 23 07 PM

test code attached:
7.1_C.txt

version:

print(sys.version)
3.7.6 (default, Jan 8 2020, 20:19:54)

results:
To
update a -> b
update a -> fin
To
To
To
check sequence:
['a', 'c', 'b', 'fin']
cost updatd:
{'a': 2, 'c': 2, 'b': 4, 'fin': 4}