1
$\begingroup$

I want to calculate the maximum flow of the network and am attempting to do that with FindMaximumFlow[edge capacity matrix, s, t, "OptimumFlowData"], which in my case is

F = FindMaximumFlow[({
{0, 2, 2, 2, 10, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 2, 0, 0, 0, 0},
{0, 2, 0, 0, 0, 0, 6, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 2, 0, 0},
{0, 0, 6, 0, 0, 0, 0, 0, 2, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 5},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 2},
{0, 0, 0, 0, 0, 0, 0, 4, 0, 6},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
}), 1, 10, "OptimumFlowData" ].

While I do get a result with this, I want to be able to use the command F["FlowGraph"] to get a network showing the optimal solution.

Here you can see that by this command the optimal graph is returned when the first parameter is the graph itself instead of the edge capacity matrix.

How can I get the optimal graph from using FindMaximumFlow with the capacity matrix or get the graph from the edge capacity matrix so I can use the graph similarly to how it's used in the example in documentation? Thank you!

$\endgroup$

1 Answer 1

3
$\begingroup$

You could build a graph using edge capacity matrix:

g = WeightedAdjacencyGraph[{{0, 2, 2, 2, 10, 0, 0, 0, 0, 0}, {0, 0, 0,
      0, 0, 2, 0, 0, 0, 0}, {0, 2, 0, 0, 0, 0, 6, 0, 0, 0}, {0, 0, 0, 
     0, 0, 0, 0, 2, 0, 0}, {0, 0, 6, 0, 0, 0, 0, 0, 2, 0}, {0, 0, 0, 
     0, 0, 0, 0, 0, 0, 5}, {0, 0, 0, 0, 0, 1, 0, 0, 0, 2}, {0, 0, 0, 
     0, 0, 0, 0, 0, 0, 2}, {0, 0, 0, 0, 0, 0, 0, 4, 0, 6}, {0, 0, 0, 
     0, 0, 0, 0, 0, 0, 0}} /. {0 -> Infinity}];

data = FindMaximumFlow[g, 1, 10, "OptimumFlowData", 
   EdgeCapacity -> EdgeWeight];

data["FlowGraph"]

enter image description here

$\endgroup$
2
  • $\begingroup$ Why does data["FlowTable"] not work? $\endgroup$
    – Szabolcs
    Commented Mar 31, 2018 at 14:44
  • $\begingroup$ Oh that's great, thank you! $\endgroup$
    – Larisa
    Commented Mar 31, 2018 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.