Reputation: 277
How do I find the index idx, such that dist[idx] is minimum, but only amongst those whose visited[idx] is false ? The context is for an implementation of Dijkstra's algorithm.
Upvotes: 0
Views: 920
Reputation: 133564
min((idx for idx in indexes if not visited[idx]), key=lambda idx: dist[idx])
Upvotes: 3