// Johnny Boldt // Mar 17, 2011 // johnny.boldt@gmail.com This is a problem known as Minimum Cut aka "min cut" If you don't know, min cut is equivalent to max flow. For more information on the theorum behind this, visit: http://en.wikipedia.org/wiki/Max-flow_min-cut_theorem Max Flow is the maximum ammount of flow from a source node to a sink node in a network flow model. The code I used for Max Flow is found in Dr. Howard Chengs library. However, there are a few additional things needed to solve this problem. Because every edge AND every node is assigned a weight, we have to replace each node with a "in" node and a "out" node. The edge put inbetween the in-node and the out-node should be the weight of the node they are replacing. A simple way to implement this is just have an offset(the number of original nodes). In this problem, the offset would be 50. For example: Node 0 is replaced by in-node 0 and out-node 50 Node 1 is replaced by in-node 0 and out-node 51 ect. Now, when setting up the edges from one node to another, you need to connect the out-node of each node to the in-node of the other node(both ways, since it's bi-directional). After everything is connected, just print the results with the max-flow function. Remember that the ammount of nodes in your graph with be OFFSET+M (though they may not all be in use).