docstr: Combinatorial Optimization: Algorithms and Complexity,
  Papadimitriou Steiglitz at page 140 has an example, 7.1, but that
  admits multiple solutions, so I alter it a bit. From ticket #430
  by mfrasca.
docstr_tok: ["Combinatorial","Optimization",":","Algorithms","and","Complexity",",","Papadimitriou","Steiglitz","at","page","140","has","an","example",",","7.1",",","but","that","admits","multiple","solutions",",","so","I","alter","it","a","bit",".","From","ticket","#","430","by","mfrasca","."]
code: def test_digraph3(self):
      """Combinatorial Optimization: Algorithms and Complexity,
      Papadimitriou Steiglitz at page 140 has an example, 7.1, but that
      admits multiple solutions, so I alter it a bit. From ticket #430
      by mfrasca."""
  
      G = nx.DiGraph()
      G.add_edge("s", "a")
      G["s"]["a"].update({0: 2, 1: 4})
      G.add_edge("s", "b")
      G["s"]["b"].update({0: 2, 1: 1})
      G.add_edge("a", "b")
      G["a"]["b"].update({0: 5, 1: 2})
      G.add_edge("a", "t")
      G["a"]["t"].update({0: 1, 1: 5})
      G.add_edge("b", "a")
      G["b"]["a"].update({0: 1, 1: 3})
      G.add_edge("b", "t")
      G["b"]["t"].update({0: 3, 1: 2})
  
      "PS.ex.7.1: testing main function"
      sol = nx.max_flow_min_cost(G, "s", "t", capacity=0, weight=1)
      flow = sum(v for v in sol["s"].values())
      assert 4 == flow
      assert 23 == nx.cost_of_flow(G, sol, weight=1)
      assert sol["s"] == {"a": 2, "b": 2}
      assert sol["a"] == {"b": 1, "t": 1}
      assert sol["b"] == {"a": 0, "t": 3}
      assert sol["t"] == {}
  
      G.add_edge("t", "s")
      G["t"]["s"].update({1: -100})
      flowCost, sol = nx.capacity_scaling(G, capacity=0, weight=1)
      G.remove_edge("t", "s")
      flow = sum(v for v in sol["s"].values())
      assert 4 == flow
      assert sol["t"]["s"] == 4
      assert flowCost == -377
      del sol["t"]["s"]
      assert sol["s"] == {"a": 2, "b": 2}
      assert sol["a"] == {"b": 1, "t": 1}
      assert sol["b"] == {"a": 0, "t": 3}
      assert sol["t"] == {}
      assert nx.cost_of_flow(G, sol, weight=1) == 23
  
imports: import bz2
  import importlib.resources
  import os
  import pickle
  import pytest
  import networkx
label_desc: Use image node_id 9 for calling the TestMinCostFlow obj's underlying member method code with example usage: obj.test_digraph3() without return types