minimum
How can I find the minimum cut on a graph using a maximum flow algorithm?
From the source vertex, do a depth-first search along edges in the residual network (i.e., non-saturated edges and back edges of edges that have flow), and mark all vertices that can be reached this way. The cut consists of all edges that go from a marked to an unmarked vertex. Clearly, those edges are saturated … Read more
Python: Find index of minimum item in list of floats [duplicate]
I would use: val, idx = min((val, idx) for (idx, val) in enumerate(my_list)) Then val will be the minimum value and idx will be its index.
Numpy minimum in (row, column) format
Use unravel_index: numpy.unravel_index(A.argmin(), A.shape)
How to scale down a range of numbers with a known min and max value
Let’s say you want to scale a range [min,max] to [a,b]. You’re looking for a (continuous) function that satisfies f(min) = a f(max) = b In your case, a would be 1 and b would be 30, but let’s start with something simpler and try to map [min,max] into the range [0,1]. Putting min into … Read more
Get the key corresponding to the minimum value within a dictionary
Best: min(d, key=d.get) — no reason to interpose a useless lambda indirection layer or extract items or keys! >>> d = {320: 1, 321: 0, 322: 3} >>> min(d, key=d.get) 321