0

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?

directed_graph

PS: Here is the only question, I found relevant to this topic: python networkX network simplex

oakca
  • 1,408
  • 1
  • 18
  • 40
  • Have you tried to test it with a small part of your graph? It looks like you have 100k nodes – Sparky05 Jan 27 '22 at 07:42
  • That is the issue though, I first though it is because of the big graph. However, than I gave a bigger graph with 200k nodes. It does not create this overflow warning. @Sparky05 – oakca Jan 27 '22 at 09:10

1 Answers1

0

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.

oakca
  • 1,408
  • 1
  • 18
  • 40