def EarthMoversDistance( lengraph, supplygraph, length='length', weight1='weight1', weight2='weight2' ) :
    # lengraph is a *non*-multi DiGraph
    digraph, s, t = FLOW.obtainCapacityNetwork( lengraph, supplygraph, length, weight1, weight2 )
    #
    flowgraph = FLOW.obtainFlowNetwork( digraph, s, t, capacity='capacity' )
    costgraph = FLOW.obtainWeightedCosts( flowgraph, lengraph, weight=length )
    
    # compute optimal flow
    FLOW.max_flow_min_cost( flowgraph, costgraph )
    
    return FLOW.totalcost( costgraph ).value
예제 #2
0
def EarthMoversDistance( measurenx, length='length', weight1='weight1', weight2='weight2', DELTA=None ) :
    flowgraph, costgraph = obtainWassersteinProblem( measurenx, length, weight1, weight2 )
    flownets.max_flow_min_cost( flowgraph, costgraph )
    return flownets.totalcost( costgraph ).value