Maximum Flows on the Railway Network
Maximum Flows on the Railway Network
Based on a 1940 Soviet railway network, find the maximum amount of cargo that can be transported from sources in the Western Soviet Union to destinations in Eastern European countries.
railway = \!\(\*GraphicsBox[«6»]\);FindMaximumFlow[railway, {1, 5, 6, 7, 9, 12, 13, 18}, {44, 40}]data = FindMaximumFlow[railway, {1, 5, 6, 7, 9, 12, 13, 18}, {44, 40}, "OptimumFlowData"];makelabels[railway_, data_] := Block[{edgecap = EdgeCapacity /. Options[railway, EdgeCapacity]}, Map[(# -> Framed[Style[Row[{edgecap[[EdgeIndex[railway, #]]] , "/", data[#]}], Directive[8.2, FontFamily -> "Helvetica"]], FrameMargins -> {{-.2, -.2}, {-.7, -.7}}, Background -> GrayLevel[.9], FrameStyle -> None])&, data["EdgeList"]]
];Annotate[data["FlowGraph"], {EdgeLabels -> makelabels[railway, data]}]