I am trying to use the networkx network_simplex()
function with a directed graph.
In the official documentation it says:
This algorithm is not guaranteed to work if edge weights or demands are floating point numbers (overflows and roundoff errors can cause problems). As a workaround you can use integer numbers by multiplying the relevant edge attributes by a convenient constant factor (eg 100).
However, I am not using any float numbers on edge weights or demands, how can I fix this issue?
Here is the code piece that I am trying to run:
flow_cost, flow_dict = nx.network_simplex(directed_graph)
And below you can find the directed_graph specifications. Am I wrong, while saying that my edge weights or demands are not floating numbers?
PS: Here is the only question, I found relevant to this topic: python networkX network simplex
For me the solution was:
the weights and the demand dictionary contained numpy.int32
integers. I first changed them to numpy.int64
integers, still got the same warning. Then finally, I changed them to native python integers, meaning int()
.
It fixed the issue.