|
|
|
@ -29,6 +29,8 @@ int test_max_flow()
|
|
|
|
|
double *flow = 0;
|
|
|
|
|
double flow_value;
|
|
|
|
|
|
|
|
|
|
struct Edge **cut_edges = 0;
|
|
|
|
|
|
|
|
|
|
FILE *f = fopen("tmp/flow.in", "r");
|
|
|
|
|
abort_if(!f, "could not open input file");
|
|
|
|
|
|
|
|
|
@ -83,10 +85,36 @@ int test_max_flow()
|
|
|
|
|
struct Edge *e = &graph.edges[i];
|
|
|
|
|
if (flow[e->index] <= 0) continue;
|
|
|
|
|
|
|
|
|
|
log_info(" %d %d %6.2f / %6.2f\n", e->from->index, e->to->index, flow[e->index], capacities[e->index]);
|
|
|
|
|
log_info(" %d %d %6.2f / %6.2f\n", e->from->index, e->to->index,
|
|
|
|
|
flow[e->index], capacities[e->index]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_info("Nodes reachable from origin on residual graph:\n");
|
|
|
|
|
for (int i = 0; i < graph.node_count; i++)
|
|
|
|
|
{
|
|
|
|
|
struct Node *n = &graph.nodes[i];
|
|
|
|
|
if(n->mark)
|
|
|
|
|
log_info(" %d\n", n->index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cut_edges_count = 0;
|
|
|
|
|
cut_edges = (struct Edge**) malloc(graph.edge_count * sizeof(struct Edge*));
|
|
|
|
|
abort_if(!cut_edges, "could not allocate cut_edges");
|
|
|
|
|
|
|
|
|
|
rval = get_cut_edges_from_marks(&graph, &cut_edges_count, cut_edges);
|
|
|
|
|
abort_if(rval, "get_cut_edges_from_marks failed");
|
|
|
|
|
|
|
|
|
|
log_info("Min cut edges:\n");
|
|
|
|
|
for (int i = 0; i < cut_edges_count; i++)
|
|
|
|
|
{
|
|
|
|
|
struct Edge *e = cut_edges[i];
|
|
|
|
|
if(capacities[e->index] <= 0) continue;
|
|
|
|
|
log_info(" %d %d\n", e->from->index, e->to->index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
|
if(cut_edges) free(cut_edges);
|
|
|
|
|
if (capacities) free(capacities);
|
|
|
|
|
if (edges) free(edges);
|
|
|
|
|
if (flow) free(flow);
|
|
|
|
|