Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This problem reduces to finding a <a href="http://en.wikipedia.org/wiki/Maximum_flow_problem" rel="nofollow noreferrer">maximum flow</a> in a flow network.</p> <p>Here's the idea:</p> <ol> <li><p>For each type of resource (A, B, ...) a node with an incoming edge from the <strong>source</strong> node (the source node has nothing to do with the sources from the problem, it's a common label used in network flow theory, usually marked <strong>s</strong>) with capacity equal to the required quantity of the given resource. For example if you need <em>2B</em>, the capacity would be 2.</p></li> <li><p>For each <em>source</em> (by this I mean a source as defined by the problem description), you create a node with an outgoing edge to the sink (usually marked <strong>t</strong>) with capacity 1.</p></li> <li><p>From each node from step 1. add an outgoing edge to each of the nodes from step 2. that provide that can provide the required type of resource.</p></li> </ol> <p>For example, the graph for your situation would look like this:</p> <p><img src="https://i.stack.imgur.com/ltpln.png" alt="flow graph"></p> <p>Now a maximal S-T flow in this network will give you the answer. Basically saturated edges between the <em>type</em> nodes (A, B, C) and the <em>source</em> nodes (src1, src2, src3) will tell you which <em>source</em> should supply which <em>type</em> of resource.</p> <p>The maximum flow can be found using any of the classical algorithms, such as <strong>augmenting path</strong> (<em>Ford-Fulkerson</em>, <em>Dinic's</em>, etc.) or one of the <strong>push-relabel</strong> methods (<em>Goldberg-Tarjan</em>, <em>Relabel-to-Front</em>, etc.).</p> <p>This particular application of maximum flow can also be viewed as a sort of generalized <a href="http://en.wikipedia.org/wiki/Matching_(graph_theory)#Maximum_matchings_in_bipartite_graphs" rel="nofollow noreferrer">bipartite matching</a>, where you're matching each type of resource to possibly multiple sources, but each source can handle only one resource. The idea is easily extended to the case where a source may handle more than one type (by simply changing the <strong>src - T</strong> edge capacities from 1 to the ones desired).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload