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

REPORT BUG: running isolated graph will bring in KeyError #1

Open
Serbipunk opened this issue Mar 4, 2018 · 0 comments
Open

REPORT BUG: running isolated graph will bring in KeyError #1

Serbipunk opened this issue Mar 4, 2018 · 0 comments

Comments

@Serbipunk
Copy link

$ python dijkstra.py

    graph = {'a': {'b': 14, 'c': 9, 'd': 7},
             'b': {'a': 14, 'c': 2, 'e': 9},
             'c': {'a': 9, 'b': 2, 'd': 10, 'f': 11},
             'd': {'a': 7, 'c': 10, 'f': 15},
             'e': {'b': 9, 'f': 6},
             'f': {'c': 11, 'd': 15, 'e': 6}, 
             'g': {'h': 3},                                    # --  + isolated graph
             'h': {}}                                           # --  +

    dist, pred = dijkstra(graph, start='a')

and you will get:

Traceback (most recent call last):
  File "dijkstra.py", line 141, in <module>
    dist, pred = dijkstra(graph, start='a')
  File "dijkstra.py", line 42, in dijkstra
    (v, d) = Q.popitem()                    # node w/ min dist d on frontier
  File "/home/magnus/git/dijkstra/pqdict.py", line 451, in popitem
    raise KeyError('PQDict is empty')
KeyError: 'PQDict is empty
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