Calculate the value of a cut.

    @type graph: digraph
    @param graph: Graph

    @type flow: dictionary
    @param flow: Dictionary containing a flow for each edge.

    @type cut: dictionary
    @param cut: Dictionary mapping each node to a subset index. The function only considers the flow between
    nodes with 0 and 1.
    
    @rtype: float
    @return: The value of the flow between the subsets 0 and 1

def cut_value(graph, flow, cut):
    """
    Calculate the value of a cut.

    @type graph: digraph
    @param graph: Graph

    @type flow: dictionary
    @param flow: Dictionary containing a flow for each edge.

    @type cut: dictionary
    @param cut: Dictionary mapping each node to a subset index. The function only considers the flow between
    nodes with 0 and 1.
    
    @rtype: float
    @return: The value of the flow between the subsets 0 and 1
    """
    #max flow/min cut value calculation
    S = []
    T = []
    for node in cut.keys():
        if cut[node] == 0:
            S.append(node)
        elif cut[node] == 1:
            T.append(node)
    value = 0
    for node in S:
        for neigh in graph.neighbors(node):
            if neigh in T:
                value = value + flow[(node,neigh)]
        for inc in graph.incidents(node):
            if inc in T:
                value = value - flow[(inc,node)]    
    return value